Submission #340467

# Submission time Handle Problem Language Result Execution time Memory
340467 2020-12-27T16:36:28 Z A_D Preokret (COCI19_preokret) C++14
50 / 50
1 ms 384 KB
/*
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

preokret.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct