Submission #306319

#TimeUsernameProblemLanguageResultExecution timeMemory
306319dolijanPreokret (COCI19_preokret)C++14
50 / 50
1 ms256 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a=0,b=0; int ties=0; vector<int> golovi; for(int i=0;i<n;i++) { if(a==b) ties++; int gol; cin>>gol; golovi.push_back(gol); if(gol==1) a++; else b++; } int ta=0,tb=0; int i=1; int mx=0; while(i<n) { int t=1; while(i<n && golovi[i]==golovi[i-1]) { i++; t++; } if(golovi[i-1]==1) { if(ta<tb && ta+t>tb) mx=max(mx,t); ta+=t; } else { if(tb<ta && tb+t>ta) mx=max(mx,t); tb+=t; } i++; } if(a==b) ties++; cout<<a<<" "<<b<<endl; cout<<ties<<endl; cout<<mx<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...