# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51658 | 2018-06-19T18:06:39 Z | gs13105 | 스탬프 수집 (JOI16_ho_t2) | C++17 | 7 ms | 3840 KB |
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; char arr[100010]; long long J[100010]; long long JO[100010]; long long I[100010]; long long OI[100010]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, i; scanf("%d%s", &n, arr + 1); for(i = 1; i <= n; i++) J[i] = (arr[i] == 'J' ? 1 : 0) + J[i - 1]; for(i = 1; i <= n; i++) JO[i] = (arr[i] == 'O' ? J[i - 1] : 0) + JO[i - 1]; for(i = n; i >= 1; i--) I[i] = (arr[i] == 'I' ? 1 : 0) + I[i + 1]; for(i = n; i >= 1; i--) OI[i] = (arr[i] == 'O' ? I[i + 1] : 0) + OI[i + 1]; long long JOI = 0; for(i = 1; i <= n; i++) if(arr[i] == 'I') JOI += JO[i - 1]; long long res = 0; for(i = 0; i <= n; i++) { res = max(OI[i + 1], res); // J res = max(J[i] * I[i+1], res); // O res = max(JO[i], res); // I } res += JOI; printf("%lld\n", res); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 652 KB | Output is correct |
10 | Correct | 2 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 2 ms | 676 KB | Output is correct |
14 | Correct | 3 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 652 KB | Output is correct |
10 | Correct | 2 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 2 ms | 676 KB | Output is correct |
14 | Correct | 3 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 2 ms | 676 KB | Output is correct |
18 | Correct | 2 ms | 740 KB | Output is correct |
19 | Correct | 3 ms | 740 KB | Output is correct |
20 | Correct | 2 ms | 740 KB | Output is correct |
21 | Correct | 2 ms | 740 KB | Output is correct |
22 | Correct | 2 ms | 740 KB | Output is correct |
23 | Correct | 2 ms | 740 KB | Output is correct |
24 | Correct | 2 ms | 740 KB | Output is correct |
25 | Correct | 2 ms | 740 KB | Output is correct |
26 | Correct | 2 ms | 740 KB | Output is correct |
27 | Correct | 2 ms | 740 KB | Output is correct |
28 | Correct | 2 ms | 740 KB | Output is correct |
29 | Correct | 2 ms | 740 KB | Output is correct |
30 | Correct | 2 ms | 740 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 652 KB | Output is correct |
10 | Correct | 2 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 2 ms | 676 KB | Output is correct |
14 | Correct | 3 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 2 ms | 676 KB | Output is correct |
18 | Correct | 2 ms | 740 KB | Output is correct |
19 | Correct | 3 ms | 740 KB | Output is correct |
20 | Correct | 2 ms | 740 KB | Output is correct |
21 | Correct | 2 ms | 740 KB | Output is correct |
22 | Correct | 2 ms | 740 KB | Output is correct |
23 | Correct | 2 ms | 740 KB | Output is correct |
24 | Correct | 2 ms | 740 KB | Output is correct |
25 | Correct | 2 ms | 740 KB | Output is correct |
26 | Correct | 2 ms | 740 KB | Output is correct |
27 | Correct | 2 ms | 740 KB | Output is correct |
28 | Correct | 2 ms | 740 KB | Output is correct |
29 | Correct | 2 ms | 740 KB | Output is correct |
30 | Correct | 2 ms | 740 KB | Output is correct |
31 | Correct | 5 ms | 3836 KB | Output is correct |
32 | Correct | 5 ms | 3836 KB | Output is correct |
33 | Correct | 6 ms | 3840 KB | Output is correct |
34 | Correct | 6 ms | 3840 KB | Output is correct |
35 | Correct | 6 ms | 3840 KB | Output is correct |
36 | Correct | 7 ms | 3840 KB | Output is correct |
37 | Correct | 7 ms | 3840 KB | Output is correct |
38 | Correct | 7 ms | 3840 KB | Output is correct |
39 | Correct | 7 ms | 3840 KB | Output is correct |
40 | Correct | 7 ms | 3840 KB | Output is correct |
41 | Correct | 6 ms | 3840 KB | Output is correct |
42 | Correct | 7 ms | 3840 KB | Output is correct |
43 | Correct | 6 ms | 3840 KB | Output is correct |
44 | Correct | 6 ms | 3840 KB | Output is correct |
45 | Correct | 6 ms | 3840 KB | Output is correct |