답안 #210251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210251 2020-03-17T00:30:18 Z pavement JOIOJI (JOI14_joioji) C++17
100 / 100
52 ms 10024 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, A, JP[200005], OP[200005], IP[200005];
char S[200005];
map<pair<int, int>, int> M;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i];
		JP[i] = JP[i - 1];
		OP[i] = OP[i - 1];
		IP[i] = IP[i - 1];
		if (S[i] == 'J') JP[i]++;
		else if (S[i] == 'O') OP[i]++;
		else IP[i]++;
	}
	M[make_pair(0, 0)] = 0;
	for (int i = 1; i <= N; i++) {
		if (M.find(make_pair(JP[i] - OP[i], OP[i] - IP[i])) != M.end()) A = max(A, i - M[make_pair(JP[i] - OP[i], OP[i] - IP[i])]);
		else M[make_pair(JP[i] - OP[i], OP[i] - IP[i])] = i;
	}
	cout << A << '\n';
}

Compilation message

joioji.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 380 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 6 ms 508 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 888 KB Output is correct
2 Correct 12 ms 1784 KB Output is correct
3 Correct 16 ms 2680 KB Output is correct
4 Correct 28 ms 4728 KB Output is correct
5 Correct 40 ms 7032 KB Output is correct
6 Correct 50 ms 8312 KB Output is correct
7 Correct 52 ms 8824 KB Output is correct
8 Correct 50 ms 8312 KB Output is correct
9 Correct 50 ms 8568 KB Output is correct
10 Correct 50 ms 8312 KB Output is correct
11 Correct 43 ms 9336 KB Output is correct
12 Correct 39 ms 6776 KB Output is correct
13 Correct 35 ms 6136 KB Output is correct
14 Correct 38 ms 10024 KB Output is correct
15 Correct 28 ms 6008 KB Output is correct