# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306319 | dolijan | Preokret (COCI19_preokret) | C++14 | 1 ms | 256 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |