# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
156032 | 2019-10-03T01:11:50 Z | EntityIT | JOIOJI (JOI14_joioji) | C++14 | 102 ms | 18168 KB |
#include<bits/stdc++.h> using namespace std; const int N = (int)2e5 + 5; int n, prefJ[N], prefO[N], prefI[N], ans; map< pair<int, int>, set<int> > pos; int main() { scanf(" %d", &n); pos[ make_pair(prefJ[0] - prefO[0], prefO[0] - prefI[0]) ].insert(0); for (int i = 1; i <= n; ++i) { prefJ[i] = prefJ[i - 1]; prefO[i] = prefO[i - 1]; prefI[i] = prefI[i - 1]; char c; scanf(" %c", &c); if (c == 'J') ++prefJ[i]; if (c == 'O') ++prefO[i]; if (c == 'I') ++prefI[i]; pos[ make_pair(prefJ[i] - prefO[i], prefO[i] - prefI[i]) ].insert(i); } for (auto _ : pos) { ans = max(ans, *_.second.rbegin() - *_.second.begin() ); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 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 | 296 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 | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 632 KB | Output is correct |
4 | Correct | 4 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 760 KB | Output is correct |
6 | Correct | 3 ms | 632 KB | Output is correct |
7 | Correct | 3 ms | 632 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 4 ms | 760 KB | Output is correct |
10 | Correct | 4 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1144 KB | Output is correct |
2 | Correct | 14 ms | 3064 KB | Output is correct |
3 | Correct | 23 ms | 4856 KB | Output is correct |
4 | Correct | 46 ms | 8924 KB | Output is correct |
5 | Correct | 82 ms | 13544 KB | Output is correct |
6 | Correct | 102 ms | 16636 KB | Output is correct |
7 | Correct | 95 ms | 17144 KB | Output is correct |
8 | Correct | 94 ms | 16244 KB | Output is correct |
9 | Correct | 97 ms | 16760 KB | Output is correct |
10 | Correct | 92 ms | 16376 KB | Output is correct |
11 | Correct | 77 ms | 17400 KB | Output is correct |
12 | Correct | 78 ms | 13916 KB | Output is correct |
13 | Correct | 69 ms | 13048 KB | Output is correct |
14 | Correct | 76 ms | 18168 KB | Output is correct |
15 | Correct | 70 ms | 13048 KB | Output is correct |