# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223615 | Haunted_Cpp | Preokret (COCI19_preokret) | C++17 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cstring>
#include <algorithm>
#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a = 0, b = 0, res = 1, turnaround = 0, streak = 0, last = -1;
auto update = [&] () {
if (last == 1 && a > b) {
turnaround = max (turnaround, streak);
}
if (last == 2 && b > a) {
turnaround = max (turnaround, streak);
}
};
for (int i = 0; i < n; i++) {
int foo;
cin >> foo;
if (foo == last) {
++streak;
update ();
} else {
update ();
streak = 1;
}
last = foo;
if (foo == 1) ++a;
else ++b;
res += (a == b);
}
update ();
cout << a << ' ' << b << '\n';
cout << res << '\n';
cout << turnaround << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |