# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52141 | 2018-06-24T07:04:21 Z | ainta | None (JOI16_ho_t2) | C++17 | 5 ms | 3488 KB |
#include<cstdio> #include<algorithm> using namespace std; int C[101000][3]; int n; char p[101000]; long long s = 0, res, s2 = 0, M; int main() { int i, j; scanf("%d", &n); scanf("%s", p + 1); for (i = 1; i <= n; i++) { for (j = 0; j < 3; j++)C[i][j] = C[i - 1][j]; if (p[i] == 'J')C[i][0]++; if (p[i] == 'O') { s += C[i][0]; C[i][1]++; } if (p[i] == 'I') { C[i][2]++; res += s; } } int c = 0; for (i = n; i >= 1; i--) { if (p[i] == 'I')c++; if (p[i] == 'O')s2 += c; } M = max(s2, s); for (i = 0; i <= n; i++) { M = max(M, 1ll*C[i][0] * (C[n][2] - C[i][2])); } printf("%lld\n", res + M); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Correct | 3 ms | 584 KB | Output is correct |
5 | Correct | 2 ms | 584 KB | Output is correct |
6 | Correct | 2 ms | 584 KB | Output is correct |
7 | Correct | 2 ms | 584 KB | Output is correct |
8 | Correct | 2 ms | 584 KB | Output is correct |
9 | Correct | 2 ms | 584 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 660 KB | Output is correct |
12 | Correct | 2 ms | 660 KB | Output is correct |
13 | Correct | 2 ms | 660 KB | Output is correct |
14 | Correct | 2 ms | 660 KB | Output is correct |
15 | Correct | 2 ms | 668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Correct | 3 ms | 584 KB | Output is correct |
5 | Correct | 2 ms | 584 KB | Output is correct |
6 | Correct | 2 ms | 584 KB | Output is correct |
7 | Correct | 2 ms | 584 KB | Output is correct |
8 | Correct | 2 ms | 584 KB | Output is correct |
9 | Correct | 2 ms | 584 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 660 KB | Output is correct |
12 | Correct | 2 ms | 660 KB | Output is correct |
13 | Correct | 2 ms | 660 KB | Output is correct |
14 | Correct | 2 ms | 660 KB | Output is correct |
15 | Correct | 2 ms | 668 KB | Output is correct |
16 | Correct | 2 ms | 696 KB | Output is correct |
17 | Correct | 2 ms | 700 KB | Output is correct |
18 | Correct | 2 ms | 704 KB | Output is correct |
19 | Correct | 2 ms | 708 KB | Output is correct |
20 | Correct | 2 ms | 712 KB | Output is correct |
21 | Correct | 2 ms | 716 KB | Output is correct |
22 | Correct | 2 ms | 720 KB | Output is correct |
23 | Correct | 2 ms | 724 KB | Output is correct |
24 | Correct | 2 ms | 856 KB | Output is correct |
25 | Correct | 3 ms | 856 KB | Output is correct |
26 | Correct | 2 ms | 856 KB | Output is correct |
27 | Correct | 2 ms | 856 KB | Output is correct |
28 | Correct | 2 ms | 856 KB | Output is correct |
29 | Correct | 2 ms | 856 KB | Output is correct |
30 | Correct | 2 ms | 856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Correct | 3 ms | 584 KB | Output is correct |
5 | Correct | 2 ms | 584 KB | Output is correct |
6 | Correct | 2 ms | 584 KB | Output is correct |
7 | Correct | 2 ms | 584 KB | Output is correct |
8 | Correct | 2 ms | 584 KB | Output is correct |
9 | Correct | 2 ms | 584 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 660 KB | Output is correct |
12 | Correct | 2 ms | 660 KB | Output is correct |
13 | Correct | 2 ms | 660 KB | Output is correct |
14 | Correct | 2 ms | 660 KB | Output is correct |
15 | Correct | 2 ms | 668 KB | Output is correct |
16 | Correct | 2 ms | 696 KB | Output is correct |
17 | Correct | 2 ms | 700 KB | Output is correct |
18 | Correct | 2 ms | 704 KB | Output is correct |
19 | Correct | 2 ms | 708 KB | Output is correct |
20 | Correct | 2 ms | 712 KB | Output is correct |
21 | Correct | 2 ms | 716 KB | Output is correct |
22 | Correct | 2 ms | 720 KB | Output is correct |
23 | Correct | 2 ms | 724 KB | Output is correct |
24 | Correct | 2 ms | 856 KB | Output is correct |
25 | Correct | 3 ms | 856 KB | Output is correct |
26 | Correct | 2 ms | 856 KB | Output is correct |
27 | Correct | 2 ms | 856 KB | Output is correct |
28 | Correct | 2 ms | 856 KB | Output is correct |
29 | Correct | 2 ms | 856 KB | Output is correct |
30 | Correct | 2 ms | 856 KB | Output is correct |
31 | Correct | 4 ms | 2040 KB | Output is correct |
32 | Correct | 4 ms | 2140 KB | Output is correct |
33 | Correct | 4 ms | 2256 KB | Output is correct |
34 | Correct | 5 ms | 2356 KB | Output is correct |
35 | Correct | 4 ms | 2512 KB | Output is correct |
36 | Correct | 5 ms | 2612 KB | Output is correct |
37 | Correct | 5 ms | 2672 KB | Output is correct |
38 | Correct | 5 ms | 2828 KB | Output is correct |
39 | Correct | 5 ms | 2984 KB | Output is correct |
40 | Correct | 5 ms | 3020 KB | Output is correct |
41 | Correct | 5 ms | 3088 KB | Output is correct |
42 | Correct | 4 ms | 3188 KB | Output is correct |
43 | Correct | 5 ms | 3288 KB | Output is correct |
44 | Correct | 5 ms | 3388 KB | Output is correct |
45 | Correct | 4 ms | 3488 KB | Output is correct |