# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404453 | 2021-05-14T12:26:54 Z | radaiosm7 | JJOOII 2 (JOI20_ho_t2) | C++ | 12 ms | 1996 KB |
#include <bits/stdc++.h> using namespace std; int n, k, f, one, two, three; vector<int> j; vector<int> o; vector<int> i; char word[200005]; int ans; int main() { scanf("%d%d", &n, &k); scanf("\n%s", word); f = strlen(word); ans = INT_MAX; for (f=0; f < n; ++f) { if (word[f] == 'J') { j.push_back(f); } else if (word[f] == 'O') { o.push_back(f); } else { i.push_back(f); } } for (one=k-1; one < (int)j.size(); ++one) { two = upper_bound(o.begin(), o.end(), j[one])-o.begin(); if (two+k-1 >= (int)o.size()) { continue; } three = upper_bound(i.begin(), i.end(), o[two+k-1])-i.begin(); if (three+k-1 >= (int)i.size()) { continue; } ans = min(ans, max(0, i[three+k-1]-j[one-k+1]+1-3*k)); } if (ans == INT_MAX) { printf("-1\n"); } else { printf("%d\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 300 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 204 KB | Output is correct |
33 | Correct | 1 ms | 204 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 300 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 204 KB | Output is correct |
33 | Correct | 1 ms | 204 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 11 ms | 1544 KB | Output is correct |
37 | Correct | 12 ms | 1776 KB | Output is correct |
38 | Correct | 12 ms | 1944 KB | Output is correct |
39 | Correct | 11 ms | 1968 KB | Output is correct |
40 | Correct | 9 ms | 1848 KB | Output is correct |
41 | Correct | 10 ms | 1864 KB | Output is correct |
42 | Correct | 11 ms | 1864 KB | Output is correct |
43 | Correct | 5 ms | 1228 KB | Output is correct |
44 | Correct | 6 ms | 1356 KB | Output is correct |
45 | Correct | 9 ms | 1996 KB | Output is correct |
46 | Correct | 8 ms | 1864 KB | Output is correct |
47 | Correct | 8 ms | 1864 KB | Output is correct |
48 | Correct | 8 ms | 1992 KB | Output is correct |
49 | Correct | 6 ms | 1352 KB | Output is correct |
50 | Correct | 8 ms | 1868 KB | Output is correct |
51 | Correct | 8 ms | 1868 KB | Output is correct |
52 | Correct | 6 ms | 1480 KB | Output is correct |
53 | Correct | 7 ms | 1864 KB | Output is correct |
54 | Correct | 6 ms | 1992 KB | Output is correct |
55 | Correct | 4 ms | 1992 KB | Output is correct |
56 | Correct | 3 ms | 1992 KB | Output is correct |