Submission #498982

#TimeUsernameProblemLanguageResultExecution timeMemory
498982inksamuraiPreokret (COCI19_preokret)C++17
50 / 50
1 ms204 KiB
#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 timeMemoryGrader output
Fetching results...