# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339690 | Hazem | Preokret (COCI19_preokret) | C++14 | 1 ms | 364 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.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 2e5 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
int a[N];
int cnt[N][3];
int main()
{
//freopen("out.txt","w",stdout);
int n,ties = 1,mx = 0,cur = 1;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
cnt[i][1] = cnt[i-1][1]+(a[i]==1);
cnt[i][2] = cnt[i-1][2]+(a[i]==2);
if(a[i]==a[i-1])cur++;
else cur = 1;
if(cnt[i-cur][a[i]]<cnt[i-cur][3-a[i]]&&cnt[i][a[i]]>cnt[i][3-a[i]])mx = max(mx,cur);
ties += cnt[i][1]==cnt[i][2];
}
printf("%d %d\n%d\n%d\n",cnt[n][1],cnt[n][2],ties,mx);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |