# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
579816 |
2022-06-20T02:08:20 Z |
AGE |
Preokret (COCI19_preokret) |
C++14 |
|
1 ms |
300 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++;
}
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
preokret.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
296 KB |
Output is partially correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
296 KB |
Output is partially correct |
7 |
Partially correct |
1 ms |
288 KB |
Output is partially correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |