답안 #685171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685171 2023-01-23T16:14:01 Z Farhan_HY Preokret (COCI19_preokret) C++14
50 / 50
1 ms 328 KB
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 205;
const int M = 1e3 + 3;
const int inf = 1e18;
const int mod = 1e9 + 7;
int n, team1, team2;

main() {
    IOS
    cin >> n;
    int cnt1 = 0, cnt2 = 0, mx = 0, tie = 1;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 1) {
            cnt1++;
            cnt2 = 0;
            team1++;
            if (team1 > team2 && team1 - cnt1 < team2)
                mx = max(mx, cnt1);
        }
        else {
            cnt2++;
            cnt1 = 0;
            team2++;
            if (team2 > team1 && team2 - cnt2 < team1)
                mx = max(mx, cnt2);
        }
        tie += team1 == team2;
    }
    cout << team1 << ' ' << team2 << '\n' << tie << '\n' << mx;
}

Compilation message

preokret.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct