# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
229226 | VEGAnn | Preokret (COCI19_preokret) | C++14 | 5 ms | 384 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;
const int N = 310;
int a[N], kl = 0, ans = 1, n, sch[N][2];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
kl += bool(a[i] == 1);
sch[i][0] = kl;
sch[i][1] = i + 1 - kl;
if (kl == i + 1 - kl)
ans++;
}
cout << kl << " " << n - kl << '\n';
cout << ans << '\n';
ans = 0;
for (int tp = 0; tp < 2; tp++)
for (int i = 0; i < n; i++){
if (sch[i][tp] <= sch[i][tp ^ 1]) continue;
int len = 1;
for (int j = i + 1; j < n; j++){
if (sch[j][tp] != sch[j - 1][tp]) break;
len++;
}
if (sch[i + len - 1][tp ^ 1] > sch[i][tp])
ans = max(ans, len - 1);
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |