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 <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
typedef pair <int,int> ppair;
typedef pair <ppair,int> pppair;
map <pppair,int> Map;
map <pppair,int> :: iterator it;
int N, J, O, I, Ans;
char S[200002];
void input(void) {
scanf("%d %s",&N,&S[1]);
}
void process(void) {
int i, temp;
Map.insert(make_pair(make_pair(make_pair(0,0),0),0));
for(i=1 ; i<=N ; i++) {
if(S[i]=='J')
J++;
else if(S[i]=='O')
O++;
else
I++;
temp=min(min(J,O),I);
it=Map.find(make_pair(make_pair(J-temp,O-temp),I-temp));
if(it==Map.end())
Map.insert(make_pair(make_pair(make_pair(J-temp,O-temp),I-temp),i));
else
if(Ans<i-it->second)
Ans=i-it->second;
}
}
void output(void) {
printf("%d",Ans);
}
int main(void) {
input();
process();
output();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |