Submission #152586

# Submission time Handle Problem Language Result Execution time Memory
152586 2019-09-08T13:43:58 Z oolimry JOIOJI (JOI14_joioji) C++14
0 / 100
1000 ms 760 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int I = 0;
	int J = 0;
	int O = 0;
	typedef pair<int,int> ii;
	map<ii,int> m;
	for(int i = 0;i < n;i++){
		if(s[i] == 'I') I++;
		else if(s[i] == 'O') O++;
		else J++;
		m[ii(J-O,I-O)] = i;
	}
	I = 0, J = 0, O = 0;
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(m[ii(O-J,O-I)] > i)
			ans = max(ans,m[ii(O-J,O-I)] - i + 1);
		if(s[i] == 'I') I++;
		else if(s[i] == 'O') O++;
		else J++;
	}
    if(ans % 3 != 0) while(true) continue;
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -