# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
206146 | luciocf | Preokret (COCI19_preokret) | C++14 | 5 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++;
}
printf("%d %d\n%d\n%d\n", q1, q2, emp, turn);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |