답안 #6064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6064 2014-06-17T04:20:52 Z ainta JOIOJI (JOI14_joioji) C++
100 / 100
44 ms 3624 KB
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
char p[200010];
struct A{
	int a, b, ord;
	bool operator <(const A &p)const{
		return a != p.a ? a < p.a : b != p.b ? b < p.b : ord < p.ord;
	}
}w[200010];
int main()
{
	int i, t, M = 0;
	scanf("%d", &n);
	scanf("%s", p + 1);
	for (i = 1; i <= n; i++){
		w[i] = w[i - 1];
		if (p[i] == 'J')w[i].a++, w[i].b++;
		else if (p[i] == 'O')w[i].a--;
		else w[i].b--;
		w[i].ord = i;
	}
	sort(w, w + n + 1);
	for (i = 0; i <= n; i++){
		if (i && w[i].a == w[i - 1].a && w[i].b == w[i - 1].b){
			if (M < w[i].ord - t)M = w[i].ord - t;
		}
		else{
			t = w[i].ord;
		}
	}
	printf("%d\n", M);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3624 KB Output is correct
2 Correct 0 ms 3624 KB Output is correct
3 Correct 0 ms 3624 KB Output is correct
4 Correct 0 ms 3624 KB Output is correct
5 Correct 0 ms 3624 KB Output is correct
6 Correct 0 ms 3624 KB Output is correct
7 Correct 0 ms 3624 KB Output is correct
8 Correct 0 ms 3624 KB Output is correct
9 Correct 0 ms 3624 KB Output is correct
10 Correct 0 ms 3624 KB Output is correct
11 Correct 0 ms 3624 KB Output is correct
12 Correct 0 ms 3624 KB Output is correct
13 Correct 0 ms 3624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3624 KB Output is correct
2 Correct 0 ms 3624 KB Output is correct
3 Correct 0 ms 3624 KB Output is correct
4 Correct 0 ms 3624 KB Output is correct
5 Correct 0 ms 3624 KB Output is correct
6 Correct 0 ms 3624 KB Output is correct
7 Correct 0 ms 3624 KB Output is correct
8 Correct 0 ms 3624 KB Output is correct
9 Correct 0 ms 3624 KB Output is correct
10 Correct 0 ms 3624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3624 KB Output is correct
2 Correct 4 ms 3624 KB Output is correct
3 Correct 8 ms 3624 KB Output is correct
4 Correct 12 ms 3624 KB Output is correct
5 Correct 24 ms 3624 KB Output is correct
6 Correct 32 ms 3624 KB Output is correct
7 Correct 28 ms 3624 KB Output is correct
8 Correct 28 ms 3624 KB Output is correct
9 Correct 28 ms 3624 KB Output is correct
10 Correct 32 ms 3624 KB Output is correct
11 Correct 32 ms 3624 KB Output is correct
12 Correct 32 ms 3624 KB Output is correct
13 Correct 44 ms 3624 KB Output is correct
14 Correct 16 ms 3624 KB Output is correct
15 Correct 44 ms 3624 KB Output is correct