# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245241 | penguinhacker | Preokret (COCI19_preokret) | C++14 | 5 ms | 512 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 <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 |
---|---|---|---|---|
Fetching results... |