답안 #173428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173428 2020-01-04T05:27:11 Z jhwest2 JOIOJI (JOI14_joioji) C++14
100 / 100
46 ms 6276 KB
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N;
string s;
map<pii, int> mp;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);

	cin >> N >> s;

	int ans = 0;
	pii ret = {0, 0}; mp[ret] = 0;
	for (int i=0; i<s.size(); i++) {
		if (s[i] == 'J') ++ret.va, ++ret.vb;
		if (s[i] == 'O') --ret.va;
		if (s[i] == 'I') --ret.vb;

		if (mp.find(ret) == mp.end()) mp[ret] = i+1;
		else ans = max(ans, i+1 - mp[ret]);
	}

	cout << ans;
}

Compilation message

joioji.cpp: In function 'int main()':
joioji.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<s.size(); i++) {
                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 8 ms 1016 KB Output is correct
3 Correct 13 ms 1528 KB Output is correct
4 Correct 24 ms 2300 KB Output is correct
5 Correct 37 ms 3588 KB Output is correct
6 Correct 44 ms 3716 KB Output is correct
7 Correct 46 ms 4228 KB Output is correct
8 Correct 44 ms 3588 KB Output is correct
9 Correct 45 ms 3804 KB Output is correct
10 Correct 44 ms 3588 KB Output is correct
11 Correct 39 ms 5380 KB Output is correct
12 Correct 34 ms 2308 KB Output is correct
13 Correct 25 ms 1684 KB Output is correct
14 Correct 34 ms 6276 KB Output is correct
15 Correct 18 ms 1412 KB Output is correct