답안 #866415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866415 2023-10-26T05:52:03 Z vjudge1 Preokret (COCI19_preokret) C++17
44 / 50
1 ms 356 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 200000
using namespace std;
const int mod=1000000007ll;

void solve(){
    int n;
    cin>>n;
    int a=0,b=0;
    int tie=1,turn=0,cur=0,now=0;
    for(int i=0;i<n;i++){
        int tem;
        cin>>tem;
        if(tem==1){
            if(a<b){
                if(now!=1)cur=0;
                cur++;
            }
            else if(now==1){
                cur++;
                turn=max(turn,cur);
            }
            now=1;
            a++;
        }else{
            if(a>b){
                if(now!=2)cur=0;
                cur++;
            }
            else if(now==2){
                cur++;
                turn=max(turn,cur);
            }
            now=2;
            b++;
        }
        if(a==b){
            tie++;
        }
    }
    cout<<a<<" "<<b<<"\n"<<tie<<"\n"<<turn;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#else

#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Partially correct 0 ms 348 KB Output is partially correct
8 Correct 1 ms 348 KB Output is correct
9 Partially correct 0 ms 348 KB Output is partially correct
10 Correct 1 ms 356 KB Output is correct