aboutsummaryrefslogtreecommitdiff
path: root/contests/Round#809
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2022-07-18 22:11:40 +0200
committeromagdy7 <omar.professional8777@gmail.com>2022-07-18 22:11:40 +0200
commitadb97626f5553013e2758aeb136c8ffd28436627 (patch)
treefa519c03dcd6dbc61ed350351bb226a7ffd33085 /contests/Round#809
parent51c35987f270f7a19d83a11b2427a9ff7803e17c (diff)
downloadcompetitive-programming-adb97626f5553013e2758aeb136c8ffd28436627.tar.xz
competitive-programming-adb97626f5553013e2758aeb136c8ffd28436627.zip
Solved a couple of problems
Diffstat (limited to 'contests/Round#809')
-rw-r--r--contests/Round#809/A/B/C/D/E/F/main.cpp13
-rw-r--r--contests/Round#809/A/B/C/D/E/main.cpp13
-rw-r--r--contests/Round#809/A/B/C/D/main.cpp13
-rw-r--r--contests/Round#809/A/B/C/main.cpp13
-rwxr-xr-xcontests/Round#809/A/B/mainbin0 -> 31808 bytes
-rw-r--r--contests/Round#809/A/B/main.cpp58
-rw-r--r--contests/Round#809/A/B/main_input0.txt13
-rw-r--r--contests/Round#809/A/B/main_input1.txt3
-rw-r--r--contests/Round#809/A/B/main_input2.txt3
-rw-r--r--contests/Round#809/A/B/main_input3.txt3
-rw-r--r--contests/Round#809/A/B/main_output0.txt6
-rw-r--r--contests/Round#809/A/B/main_output1.txt1
-rw-r--r--contests/Round#809/A/B/main_output2.txt1
-rw-r--r--contests/Round#809/A/B/main_output3.txt1
-rwxr-xr-xcontests/Round#809/A/mainbin0 -> 42488 bytes
-rw-r--r--contests/Round#809/A/main.cpp35
-rw-r--r--contests/Round#809/A/main_input0.txt13
-rw-r--r--contests/Round#809/A/main_output0.txt6
18 files changed, 195 insertions, 0 deletions
diff --git a/contests/Round#809/A/B/C/D/E/F/main.cpp b/contests/Round#809/A/B/C/D/E/F/main.cpp
new file mode 100644
index 0000000..9549f1d
--- /dev/null
+++ b/contests/Round#809/A/B/C/D/E/F/main.cpp
@@ -0,0 +1,13 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+ }
+}
diff --git a/contests/Round#809/A/B/C/D/E/main.cpp b/contests/Round#809/A/B/C/D/E/main.cpp
new file mode 100644
index 0000000..9549f1d
--- /dev/null
+++ b/contests/Round#809/A/B/C/D/E/main.cpp
@@ -0,0 +1,13 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+ }
+}
diff --git a/contests/Round#809/A/B/C/D/main.cpp b/contests/Round#809/A/B/C/D/main.cpp
new file mode 100644
index 0000000..9549f1d
--- /dev/null
+++ b/contests/Round#809/A/B/C/D/main.cpp
@@ -0,0 +1,13 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+ }
+}
diff --git a/contests/Round#809/A/B/C/main.cpp b/contests/Round#809/A/B/C/main.cpp
new file mode 100644
index 0000000..9549f1d
--- /dev/null
+++ b/contests/Round#809/A/B/C/main.cpp
@@ -0,0 +1,13 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+ }
+}
diff --git a/contests/Round#809/A/B/main b/contests/Round#809/A/B/main
new file mode 100755
index 0000000..12f7c31
--- /dev/null
+++ b/contests/Round#809/A/B/main
Binary files differ
diff --git a/contests/Round#809/A/B/main.cpp b/contests/Round#809/A/B/main.cpp
new file mode 100644
index 0000000..90c55c2
--- /dev/null
+++ b/contests/Round#809/A/B/main.cpp
@@ -0,0 +1,58 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+bool isCool(vector<int> &a, int i) {
+ if (i == 0) {
+ return false;
+ }
+ if (a[i - 1] < a[i] && a[i + 1] < a[i]) {
+ return true;
+ }
+ return false;
+}
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int n;
+ cin >> n;
+ vector<int> a(n);
+ for (int &x : a)
+ cin >> x;
+ long long ans = 0;
+ long long mx = 0;
+ int max_cool = (n - 1) / 2;
+ int cnt = 0;
+ if(n > 3) {
+ for (int i = 1; i < n - 1; i++) {
+ if(isCool(a,i)) {
+ cnt++;
+ }
+ if (!isCool(a, i) && i % 2 == 0) {
+ ans += abs(a[i] - max(a[i - 1], a[i + 1])) + 1;
+ } else if(!isCool(a, i) && i % 2 != 0) {
+ mx += abs(a[i] - max(a[i - 1], a[i + 1])) + 1;
+ }
+ }
+ long long mx2 = 0;
+ for (int i = 1; i < n - 1; i += 3) {
+ if (!isCool(a, i)) {
+ mx2 += abs(a[i] - max(a[i - 1], a[i + 1])) + 1;
+ }
+ }
+ cerr << mx << " " << ans << " " << mx2 << endl;
+ if(cnt < max_cool) {
+ // cout << max(mx2, max(ans, mx)) << endl;
+ } else {
+ cout << min(mx2, min(ans, mx)) << endl;
+ }
+
+ } else {
+ cout << abs(a[1] - max(a[0], a[2])) + 1 << endl;
+ }
+ }
+}
diff --git a/contests/Round#809/A/B/main_input0.txt b/contests/Round#809/A/B/main_input0.txt
new file mode 100644
index 0000000..3781f01
--- /dev/null
+++ b/contests/Round#809/A/B/main_input0.txt
@@ -0,0 +1,13 @@
+6
+3
+2 1 2
+5
+1 2 1 4 3
+6
+3 1 4 5 5 2
+8
+4 2 1 3 5 3 6 1
+6
+1 10 1 1 10 1
+8
+1 10 11 1 10 11 10 1
diff --git a/contests/Round#809/A/B/main_input1.txt b/contests/Round#809/A/B/main_input1.txt
new file mode 100644
index 0000000..07c8f0a
--- /dev/null
+++ b/contests/Round#809/A/B/main_input1.txt
@@ -0,0 +1,3 @@
+1
+4
+1 2 2 1 \ No newline at end of file
diff --git a/contests/Round#809/A/B/main_input2.txt b/contests/Round#809/A/B/main_input2.txt
new file mode 100644
index 0000000..b5a46e0
--- /dev/null
+++ b/contests/Round#809/A/B/main_input2.txt
@@ -0,0 +1,3 @@
+1
+5
+1 1 1 4 3 \ No newline at end of file
diff --git a/contests/Round#809/A/B/main_input3.txt b/contests/Round#809/A/B/main_input3.txt
new file mode 100644
index 0000000..fb1fbc0
--- /dev/null
+++ b/contests/Round#809/A/B/main_input3.txt
@@ -0,0 +1,3 @@
+1
+7
+1000000000 1 1000000000 1 1000000000 1 1000000000 \ No newline at end of file
diff --git a/contests/Round#809/A/B/main_output0.txt b/contests/Round#809/A/B/main_output0.txt
new file mode 100644
index 0000000..6a9dd24
--- /dev/null
+++ b/contests/Round#809/A/B/main_output0.txt
@@ -0,0 +1,6 @@
+2
+0
+3
+3
+0
+4
diff --git a/contests/Round#809/A/B/main_output1.txt b/contests/Round#809/A/B/main_output1.txt
new file mode 100644
index 0000000..56a6051
--- /dev/null
+++ b/contests/Round#809/A/B/main_output1.txt
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/contests/Round#809/A/B/main_output2.txt b/contests/Round#809/A/B/main_output2.txt
new file mode 100644
index 0000000..56a6051
--- /dev/null
+++ b/contests/Round#809/A/B/main_output2.txt
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/contests/Round#809/A/B/main_output3.txt b/contests/Round#809/A/B/main_output3.txt
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/contests/Round#809/A/B/main_output3.txt
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/contests/Round#809/A/main b/contests/Round#809/A/main
new file mode 100755
index 0000000..8ee5ead
--- /dev/null
+++ b/contests/Round#809/A/main
Binary files differ
diff --git a/contests/Round#809/A/main.cpp b/contests/Round#809/A/main.cpp
new file mode 100644
index 0000000..9f5e962
--- /dev/null
+++ b/contests/Round#809/A/main.cpp
@@ -0,0 +1,35 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n, m;
+ cin >> n >> m;
+ vector<char> v(m, 'B');
+ vector<int> a(n);
+ set<int> vis;
+ for(int &x : a) cin >> x;
+ for(int i = 0; i < n; i++) {
+ int f = a[i] - 1;
+ int l = m - a[i];
+ if(f <= l && v[f] != 'A') {
+ v[f] = 'A';
+ } else if(f <= l && v[f] == 'A') {
+ v[l] = 'A';
+ } else if(l <= f && v[l] != 'A') {
+ v[l] = 'A';
+ } else if(l <= f && v[l] == 'A') {
+ v[f] = 'A';
+ }
+ }
+ for(auto ch : v) {
+ cout << ch;
+ }
+ cout << endl;
+ }
+}
diff --git a/contests/Round#809/A/main_input0.txt b/contests/Round#809/A/main_input0.txt
new file mode 100644
index 0000000..b09d594
--- /dev/null
+++ b/contests/Round#809/A/main_input0.txt
@@ -0,0 +1,13 @@
+6
+4 5
+1 1 3 1
+1 5
+2
+4 1
+1 1 1 1
+2 4
+1 3
+2 7
+7 5
+4 5
+5 5 3 5
diff --git a/contests/Round#809/A/main_output0.txt b/contests/Round#809/A/main_output0.txt
new file mode 100644
index 0000000..ac6b315
--- /dev/null
+++ b/contests/Round#809/A/main_output0.txt
@@ -0,0 +1,6 @@
+ABABA
+BABBB
+A
+AABB
+ABABBBB
+ABABA