Submission #13016

#TimeUsernameProblemLanguageResultExecution timeMemory
13016gs13068JOIOJI (JOI14_joioji)C++98
100 / 100
31 ms3624 KiB
#include<cstdio> #include<algorithm> std::pair<std::pair<int,int>,int> a[200001]; char s[200002]; int main() { int max=0; int i,j,n; scanf("%d%s",&n,s+1); for(i=1;i<=n;i++) { a[i].first=a[i-1].first; if(s[i]=='J') { a[i].first.first++; a[i].first.second++; } else if(s[i]=='O')a[i].first.first--; else a[i].first.second--; a[i].second=i; } std::sort(a,a+n+1); i=j=0; while(i<=n) { while(j<=n&&a[i].first==a[j].first)j++; if(max<a[j-1].second-a[i].second)max=a[j-1].second-a[i].second; i=j; } printf("%d",max); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...