# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498982 | inksamurai | Preokret (COCI19_preokret) | C++17 | 1 ms | 204 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 fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;
int main(){
_3qplfh5;
int n;
cin>>n;
vi a(n);
rep(i,n){
cin>>a[i];
}
int _a=0,_b=0,tie=1,ma=0;
for(int i=0;i<n;){
int cnt=1,t=0;
int oa=_a,ob=_b;
if(a[i]==1){
if(_a<_b) t=1;
_a++;
}else{
if(_a>_b) t=2;
_b++;
}
if(_a==_b) tie++;
while(i+1<n and a[i]==a[i+1]){
if(a[i]==1) _a++;
else _b++;
if(_a==_b) tie++;
cnt++;
i=i+1;
}
if(_a>_b){
if(t==1){
ma=max(ma,_a-oa);
}
}
if(_b>_a){
if(t==2){
ma=max(ma,_b-ob);
}
}
i=i+1;
}
cout<<_a<<" "<<_b<<"\n";
cout<<tie<<"\n";
cout<<ma<<"\n";
//
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |