#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, cnt[2]={0, 0}, tie=1, turn=0;
pair<int, int> c;
cin >> n;
vector<int> a(n);
for (int i=0; i<n; ++i)
cin >> a[i];
for (int i=0; i<n; ++i) {
if (a[i]==1) ++cnt[0];
else ++cnt[1];
if (cnt[0]==cnt[1]) ++tie;
if (a[i]>0&&a[i]==a[i-1])
++c.second;
else {
if (cnt[c.first]>cnt[c.first^1]&&cnt[c.first]-c.second<cnt[c.first^1]) turn=max(turn, c.second);
c={a[i]-1, 1};
}
}
if (cnt[c.first]>cnt[c.first^1]&&cnt[c.first]-c.second<cnt[c.first^1]) turn=max(turn, c.second);
cout << cnt[0] << ' ' << cnt[1] << '\n' << tie << '\n' << turn;
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |