# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
811148 | Pring | Preokret (COCI19_preokret) | C++14 | 0 ms | 212 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 int long long
typedef pair<int, int> pii;
const int MXN = 255;
int n, a[MXN];
pii sc[MXN];
int TIE() {
int ans = 0;
for (int i = 0; i <= n; i++) if (sc[i].first == sc[i].second) ans++;
return ans;
}
int TURN() {
int ans = 0;
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && a[i] == a[j]) j++;
if (a[i] == 1) {
if (sc[i].first < sc[i].second && sc[j].first > sc[j].second) ans = max(ans, j - i);
} else {
if (sc[i].first > sc[i].second && sc[j].first < sc[j].second) ans = max(ans, j - i);
}
}
return ans;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sc[i + 1] = sc[i];
if (a[i] == 1) sc[i + 1].first++;
else sc[i + 1].second++;
}
cout << sc[n].first << ' ' << sc[n].second << endl;
cout << TIE() << endl;
cout << TURN() << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |