Submission #61439

# Submission time Handle Problem Language Result Execution time Memory
61439 2018-07-26T02:45:19 Z sean617 JOIOJI (JOI14_joioji) C++
0 / 100
4 ms 836 KB
#include <iostream>
#include <cstdio>
using namespace std;

int n, l, r, md, ans, s[3][200005];
string a;
int main()
{
	int i, z;
	cin >> n;
	cin >> a;
	a = ' ' + a;
	for (i = 1; i <= n;i++) {
		s[0][i] = s[0][i - 1];
		s[1][i] = s[1][i - 1];
		s[2][i] = s[2][i - 1];
		if (a[i] == 'J') s[0][i]++;
		else if (a[i] == 'O') s[1][i]++;
		else s[2][i]++;
	}
	l = 0;
	r = n / 3 + 1;
	while (l < r) {
		md = (l + r) / 2;
		z = md * 3 - 1;
		for (i = 1; i + z <= n; i++) {
			if (s[0][i + z] - s[0][i - 1] == s[1][i + z] - s[1][i - 1] && s[2][i + z] - s[2][i - 1] == md) break;
		}
		if (i + z <= n) {ans = md; l = md + 1;}
		else r = md;
	}
	cout << ans * 3;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 2 ms 700 KB Output is correct
5 Correct 4 ms 700 KB Output is correct
6 Correct 3 ms 700 KB Output is correct
7 Correct 3 ms 700 KB Output is correct
8 Correct 3 ms 700 KB Output is correct
9 Correct 3 ms 700 KB Output is correct
10 Incorrect 2 ms 760 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Incorrect 3 ms 760 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 836 KB Output isn't correct
2 Halted 0 ms 0 KB -