# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206148 | luciocf | Preokret (COCI19_preokret) | C++14 | 5 ms | 376 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 maxn = 255;
int a[maxn];
int main(void)
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
int q1 = 0, q2 = 0, emp = 0;
int turn = 0;
for (int i = 1; i <= n; i++)
{
if (q1 == q2) emp++;
if (q1 <= q2 && a[i] == 1)
{
int j;
for (j = i; j <= n && a[j] == 1; j++)
;
j--;
if (q1+j-i+1 > q2) turn = max(turn, j-i+1);
}
else if (q2 <= q1 && a[i] == 2)
{
int j;
for (j = i; j <= n && a[j] == 2; j++)
;
j--;
if (q2+j-i+1 > q1) turn = max(turn, j-i+1);
}
if (a[i] == 1) q1++;
else q2++;
}
if (q1 == q2) emp++;
printf("%d %d\n%d\n%d\n", q1, q2, emp, turn);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |