Submission #156030

# Submission time Handle Problem Language Result Execution time Memory
156030 2019-10-03T00:55:38 Z HungAnhGoldIBO2020 JOIOJI (JOI14_joioji) C++14
95 / 100
57 ms 8836 KB
#include<iostream>
#include<map>
#define sum sum1
using namespace std;
const int N=2e5+2;
int sum[N][4];
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){
				continue;
			}
			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

joioji.cpp: In function 'int main()':
joioji.cpp:11:12: warning: unused variable 'k' [-Wunused-variable]
  int n,i,j,k,l,ans=0;
            ^
joioji.cpp:11:14: warning: unused variable 'l' [-Wunused-variable]
  int n,i,j,k,l,ans=0;
              ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 476 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 476 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 10 ms 1400 KB Output is correct
3 Correct 16 ms 2340 KB Output is correct
4 Correct 28 ms 3960 KB Output is correct
5 Correct 44 ms 5892 KB Output is correct
6 Correct 57 ms 6788 KB Output is correct
7 Correct 56 ms 7300 KB Output is correct
8 Correct 54 ms 6660 KB Output is correct
9 Correct 55 ms 6940 KB Output is correct
10 Correct 52 ms 6788 KB Output is correct
11 Correct 48 ms 7940 KB Output is correct
12 Correct 41 ms 5284 KB Output is correct
13 Correct 32 ms 4608 KB Output is correct
14 Correct 42 ms 8836 KB Output is correct
15 Correct 24 ms 4484 KB Output is correct