# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579816 | AGE | Preokret (COCI19_preokret) | C++14 | 1 ms | 300 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++;
}
else if(ok2==0&&x==2&&sum2<sum1){
ans=1;
ok2=1;
sum2++;
}
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |