# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366989 | 2021-02-15T22:52:29 Z | MilosMilutinovic | JOIOJI (JOI14_joioji) | C++14 | 47 ms | 6124 KB |
#include <bits/stdc++.h> using namespace std; const int N=2000050; int n; char s[N]; int main(){ scanf("%i%s",&n,s); map<pair<int,int>,int> lst; map<char,int> cnt; int ans=0; lst[{0,0}]=0; for(int i=0;i<n;i++){ cnt[s[i]]++; pair<int,int> curr; curr.first=cnt['J']-cnt['O']; curr.second=cnt['J']-cnt['I']; if(lst[curr]!=0||(curr.first==0&&curr.second==0)){ ans=max(ans,i-lst[curr]+1); }else lst[curr]=i+1; } printf("%i",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 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 | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
# | 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 | 2 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 492 KB | Output is correct |
2 | Correct | 7 ms | 1004 KB | Output is correct |
3 | Correct | 12 ms | 1388 KB | Output is correct |
4 | Correct | 22 ms | 2156 KB | Output is correct |
5 | Correct | 38 ms | 3308 KB | Output is correct |
6 | Correct | 44 ms | 3436 KB | Output is correct |
7 | Correct | 47 ms | 3948 KB | Output is correct |
8 | Correct | 44 ms | 3308 KB | Output is correct |
9 | Correct | 45 ms | 3692 KB | Output is correct |
10 | Correct | 44 ms | 3436 KB | Output is correct |
11 | Correct | 41 ms | 5100 KB | Output is correct |
12 | Correct | 33 ms | 2156 KB | Output is correct |
13 | Correct | 31 ms | 1516 KB | Output is correct |
14 | Correct | 34 ms | 6124 KB | Output is correct |
15 | Correct | 23 ms | 1132 KB | Output is correct |