#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 |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |