# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366985 | MilosMilutinovic | JOIOJI (JOI14_joioji) | C++14 | 45 ms | 6252 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;
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;
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){
ans=max(ans,i-lst[curr]+1);
}else lst[curr]=i+1;
}
printf("%i",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |