Submission #8232

#TimeUsernameProblemLanguageResultExecution timeMemory
8232baneling100JOIOJI (JOI14_joioji)C++98
100 / 100
36 ms6948 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...