답안 #156037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156037 2019-10-03T01:51:15 Z shuvi_dola JOIOJI (JOI14_joioji) C++14
95 / 100
63 ms 7944 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int cnti[N], cntj[N], cnto[N];
map <pair <int, int>, int> m;
string s;
int n;
int main()
{
	cin >> n;
	cin >> s;
	for(int i = 0; i < n; i++)
	{
		cnti[i] = cnti[i - 1] + (s[i] == 'I');
		cntj[i] = cntj[i - 1] + (s[i] == 'J');
		cnto[i] = cnto[i - 1] + (s[i] == 'O');
		pair <int, int> v1 = {cntj[i] - cnti[i], cntj[i] - cnto[i]};
		if(m[v1] == 0)
			m[v1] = i;
	}
	int ans = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		pair <int, int> v1 = {cntj[i] - cnti[i], cntj[i] - cnto[i]};
		int j = m[v1];
		ans = max(ans, i - j);
	}

	cout << ans;
}
# 결과 실행 시간 메모리 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 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 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 3 ms 376 KB Output is correct
7 Correct 3 ms 376 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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 11 ms 1272 KB Output is correct
3 Correct 17 ms 2040 KB Output is correct
4 Correct 32 ms 3320 KB Output is correct
5 Correct 49 ms 5128 KB Output is correct
6 Correct 60 ms 5768 KB Output is correct
7 Correct 63 ms 6340 KB Output is correct
8 Correct 60 ms 5640 KB Output is correct
9 Correct 62 ms 5896 KB Output is correct
10 Correct 59 ms 5768 KB Output is correct
11 Correct 55 ms 7124 KB Output is correct
12 Correct 40 ms 4360 KB Output is correct
13 Correct 38 ms 3720 KB Output is correct
14 Correct 60 ms 7944 KB Output is correct
15 Correct 35 ms 3592 KB Output is correct