Submission #579817

#TimeUsernameProblemLanguageResultExecution timeMemory
579817AGEPreokret (COCI19_preokret)C++14
29 / 50
1 ms212 KiB
#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 (stderr)

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