# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366989 | MilosMilutinovic | JOIOJI (JOI14_joioji) | C++14 | 47 ms | 6124 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;
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 (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... |