# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
202452 | 2020-02-16T07:33:54 Z | Kastanda | JJOOII 2 (JOI20_ho_t2) | C++11 | 43 ms | 5368 KB |
// In The Name Of The Queen #include<bits/stdc++.h> using namespace std; const int N = 200005; int n, k, P[3][N], Nxt[3][N]; char S[N]; int main() { scanf("%d%d%s", &n, &k, S + 1); S[++ n] = 'J'; for (int i = 1; i <= n; i ++) { if (S[i] == 'J') S[i] = 0; if (S[i] == 'O') S[i] = 1; if (S[i] == 'I') S[i] = 2; } for (int w = 0; w <= 2; w ++) for (int i = 1; i <= n; i ++) P[w][i] = P[w][i - 1] + (S[i] == w); for (int w = 0; w <= 2; w ++) for (int i = 1; i <= n; i ++) Nxt[w][i] = lower_bound(P[w], P[w] + n + 1, P[w][i - 1] + k) - P[w]; int Mn = n + 1; for (int l = 1; l <= n; l ++) { int nw = l; for (int w = 0; w <= 2; w ++) if (nw <= n) nw = Nxt[w][nw] + 1; if (nw <= n) Mn = min(Mn, nw - l - k * 3); } if (Mn > n) Mn = -1; return !printf("%d\n", Mn); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 372 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 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 |
14 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 372 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 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 |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 380 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 504 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 376 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 428 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 372 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 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 |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 380 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 504 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 376 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 428 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
36 | Correct | 37 ms | 4856 KB | Output is correct |
37 | Correct | 41 ms | 5240 KB | Output is correct |
38 | Correct | 40 ms | 5240 KB | Output is correct |
39 | Correct | 40 ms | 5112 KB | Output is correct |
40 | Correct | 37 ms | 5240 KB | Output is correct |
41 | Correct | 38 ms | 5368 KB | Output is correct |
42 | Correct | 40 ms | 5240 KB | Output is correct |
43 | Correct | 24 ms | 3320 KB | Output is correct |
44 | Correct | 29 ms | 4088 KB | Output is correct |
45 | Correct | 36 ms | 5240 KB | Output is correct |
46 | Correct | 35 ms | 5240 KB | Output is correct |
47 | Correct | 35 ms | 5240 KB | Output is correct |
48 | Correct | 35 ms | 5240 KB | Output is correct |
49 | Correct | 25 ms | 3580 KB | Output is correct |
50 | Correct | 35 ms | 5240 KB | Output is correct |
51 | Correct | 43 ms | 5240 KB | Output is correct |
52 | Correct | 28 ms | 4984 KB | Output is correct |
53 | Correct | 29 ms | 5240 KB | Output is correct |
54 | Correct | 31 ms | 5240 KB | Output is correct |
55 | Correct | 28 ms | 5240 KB | Output is correct |
56 | Correct | 26 ms | 5240 KB | Output is correct |