# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764574 | 1075508020060209tc | Preokret (COCI19_preokret) | C++14 | 1 ms | 340 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>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
int ar[500005];
int A[500005];
int B[500005];
signed main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>ar[i];
}
int rv=0;
int te=1;
for(int i=1;i<=n;i++){
A[i]=A[i-1];
B[i]=B[i-1];
if(ar[i]==1){
A[i]++;
}else{
B[i]++;
}
if(A[i]==B[i]){te++;}
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(ar[i]==1){
if(A[j]-A[i-1]!=j-i+1){continue;}
if(A[i]<B[i]&&A[j]>B[j]){
rv=max(rv,j-i+1ll);
}
}else{
if(B[j]-B[i-1]!=j-i+1){continue;}
if(B[i]<A[i]&&B[j]>A[j]){
rv=max(rv,j-i+1ll);
}
}
}
}
cout<<A[n]<<" "<<B[n]<<endl;
cout<<te<<endl;
cout<<rv<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |