답안 #579818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579818 2022-06-20T02:13:28 Z AGE Preokret (COCI19_preokret) C++14
29 / 50
1 ms 212 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pb push_back
using namespace std;
const int N=1e6,M=2e3+1,mod=1e9+7;

main(){

    int n;
    cin>>n;

    int sum1=0,sum2=0;

    int i=0;
    int x;
    int Final_ans=0;
    int ans=0;
    int ok1=0,ok2=0;
    int anss=0;

    while(i<n){

        cin>>x;

        if(ok1==1&&x==1)
            ans++,ok2=0,sum1++;

        else if(ok2==1&&x==2)
            ans++,ok1=0,sum2++;

        else if(x==1&&sum1>=sum2)
            sum1++;

        else if(x==2&&sum2>=sum1)
            sum2++;

        else if(ok1==0&&x==1&&sum1<sum2){
            ok1=1;
            ans=1;
            sum1++;
            ok2=0;
        }


        else if(ok2==0&&x==2&&sum2<sum1){

            ans=1;
            ok2=1;
            sum2++;
            ok1=0;

        }

        i++;

        if(sum1==sum2)
            anss++;

        if(ok1==1&&sum1>=sum2)
            Final_ans=max(Final_ans,ans);

        if(ok2==1&&sum2>=sum1)
            Final_ans=max(Final_ans,ans);


    }

    cout<<sum1<<" "<<sum2<<endl;
    cout<<anss+1<<endl;
    cout<<Final_ans<<endl;

    return 0;
}

Compilation message

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