답안 #6866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6866 2014-07-08T14:28:57 Z Qwaz JOIOJI (JOI14_joioji) C++
100 / 100
48 ms 6948 KB
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;
typedef pair < int, int > pii;
const int MAX = 200020;

int n, res;
char data[MAX];
map < pii, int > mp;

void solve(){
	mp[pii(0, 0)] = -1;

	int i, jSum = 0, oSum = 0, iSum = 0;
	for(i = 0; i<n; i++){
		if(data[i] == 'J') jSum++;
		else if(data[i] == 'O') oSum++;
		else iSum++;

		pii t = pii(oSum-jSum, iSum-jSum);
		if(mp.find(t) != mp.end())
			res = max(res, i-mp[t]);
		else
			mp[t] = i;
	}

	printf("%d\n", res);
}

int main(){
	scanf("%d%s", &n, data);

	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1404 KB Output is correct
11 Correct 0 ms 1404 KB Output is correct
12 Correct 0 ms 1404 KB Output is correct
13 Correct 0 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1536 KB Output is correct
2 Correct 4 ms 1932 KB Output is correct
3 Correct 12 ms 2328 KB Output is correct
4 Correct 20 ms 3120 KB Output is correct
5 Correct 36 ms 4176 KB Output is correct
6 Correct 36 ms 4308 KB Output is correct
7 Correct 48 ms 4704 KB Output is correct
8 Correct 40 ms 4176 KB Output is correct
9 Correct 44 ms 4440 KB Output is correct
10 Correct 36 ms 4176 KB Output is correct
11 Correct 32 ms 5892 KB Output is correct
12 Correct 20 ms 2988 KB Output is correct
13 Correct 20 ms 2328 KB Output is correct
14 Correct 40 ms 6948 KB Output is correct
15 Correct 24 ms 1932 KB Output is correct