답안 #13016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13016 2015-01-25T03:18:24 Z gs13068 JOIOJI (JOI14_joioji) C++
100 / 100
31 ms 3624 KB
#include<cstdio>
#include<algorithm>

std::pair<std::pair<int,int>,int> a[200001];
char s[200002];

int main()
{
	int max=0;
	int i,j,n;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;i++)
	{
		a[i].first=a[i-1].first;
		if(s[i]=='J')
		{
			a[i].first.first++;
			a[i].first.second++;
		}
		else if(s[i]=='O')a[i].first.first--;
		else a[i].first.second--;
		a[i].second=i;
	}
	std::sort(a,a+n+1);
	i=j=0;
	while(i<=n)
	{
		while(j<=n&&a[i].first==a[j].first)j++;
		if(max<a[j-1].second-a[i].second)max=a[j-1].second-a[i].second;
		i=j;
	}
	printf("%d",max);
}
# 결과 실행 시간 메모리 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 1 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 1 ms 3624 KB Output is correct
12 Correct 0 ms 3624 KB Output is correct
13 Correct 1 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 2 ms 3624 KB Output is correct
6 Correct 0 ms 3624 KB Output is correct
7 Correct 2 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 6 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 22 ms 3624 KB Output is correct
6 Correct 31 ms 3624 KB Output is correct
7 Correct 30 ms 3624 KB Output is correct
8 Correct 30 ms 3624 KB Output is correct
9 Correct 31 ms 3624 KB Output is correct
10 Correct 27 ms 3624 KB Output is correct
11 Correct 19 ms 3624 KB Output is correct
12 Correct 31 ms 3624 KB Output is correct
13 Correct 17 ms 3624 KB Output is correct
14 Correct 13 ms 3624 KB Output is correct
15 Correct 24 ms 3624 KB Output is correct