# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339690 | 2020-12-25T23:33:26 Z | Hazem | Preokret (COCI19_preokret) | C++14 | 1 ms | 364 KB |
/* 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |