Submission #245241

#TimeUsernameProblemLanguageResultExecution timeMemory
245241penguinhackerPreokret (COCI19_preokret)C++14
50 / 50
5 ms512 KiB
#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 timeMemoryGrader output
Fetching results...