답안 #156031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156031 2019-10-03T00:58:00 Z HungAnhGoldIBO2020 JOIOJI (JOI14_joioji) C++14
100 / 100
54 ms 9220 KB
#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

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;
              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 764 KB Output is correct
2 Correct 9 ms 1528 KB Output is correct
3 Correct 15 ms 2424 KB Output is correct
4 Correct 27 ms 4216 KB Output is correct
5 Correct 42 ms 6276 KB Output is correct
6 Correct 52 ms 7348 KB Output is correct
7 Correct 54 ms 7940 KB Output is correct
8 Correct 51 ms 7300 KB Output is correct
9 Correct 52 ms 7556 KB Output is correct
10 Correct 51 ms 7300 KB Output is correct
11 Correct 48 ms 8452 KB Output is correct
12 Correct 40 ms 5892 KB Output is correct
13 Correct 31 ms 5252 KB Output is correct
14 Correct 42 ms 9220 KB Output is correct
15 Correct 22 ms 5124 KB Output is correct