# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156031 | HungAnhGoldIBO2020 | JOIOJI (JOI14_joioji) | C++14 | 54 ms | 9220 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<iostream>
#include<map>
#define sum sum1
using namespace std;
const int N=2e5+2;
int sum[N][5];
map<pair<int,int>,int> min1;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,i,j,k,l,ans=0;
string s;
cin>>n>>s;
min1[{0,0}]=0;
for(i=0;i<n;i++){
for(j=1;j<=3;j++){
sum[1+i][j]=sum[i][j];
}
if(s[i]=='J'){
sum[i+1][1]++;
}
if(s[i]=='O'){
sum[i+1][2]++;
}
if(s[i]=='I'){
sum[i+1][3]++;
}
if(min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]==0){
if(sum1[i+1][1]-sum1[i+1][2]==0&&sum1[i+1][2]-sum[i+1][3]==0){
}
else{
min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]=i+1;
}
}
ans=max(ans,i+1-min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]);
}
cout<<ans;
}
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... |