# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
245241 | penguinhacker | Preokret (COCI19_preokret) | C++14 | 5 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |