Submission #340467

#TimeUsernameProblemLanguageResultExecution timeMemory
340467A_DPreokret (COCI19_preokret)C++14
50 / 50
1 ms384 KiB
/*
ID: antwand1
TASK: barn1
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define du long double
#define F first
#define S second
using namespace std;
int a[2];
main()
{
    //freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout);
    int n,ti=1,cnt=0,mx=0,ok=0;
    cin>>n;
    int u=-1;
    while(n--){
        int k;
        cin>>k;k--;
        a[k]++;
        if(a[0]==a[1])ti++;
        if(u==-1||u==k){
            cnt++;
        }
        else{
            cnt=1;
            ok=0;
        }
        u=k;
        if(cnt>=2&&a[k]==a[k^1]+1){
            ok=1;
        }
        if(ok)mx=max(mx,cnt);
    }
    cout<<a[0]<<" "<<a[1]<<endl;
    cout<<ti<<endl;
    cout<<mx<<endl;
}




Compilation message (stderr)

preokret.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...