# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520634 | 2022-01-30T12:58:45 Z | aris12345678 | JJOOII 2 (JOI20_ho_t2) | C++14 | 13 ms | 2004 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); string s; cin >> s; vector<int> a, b, c; for(int i = 0; i < n; i++) { if(s[i] == 'J') a.push_back(i); else if(s[i] == 'O') b.push_back(i); else c.push_back(i); } int ans = INT_MAX; for(int i = k-1; i < (int)a.size(); i++) { // cout << a[i] << "\n"; int j = upper_bound(b.begin(), b.end(), a[i])-b.begin(); // cout << b[j] << "\n"; if(j+k-1 >= (int)b.size()) break; int u = upper_bound(c.begin(), c.end(), b[j+k-1])-c.begin(); if(u+k-1 >= (int)c.size()) break; // cout << a[i-k+1] << " " << c[u+k-1] << "\n"; ans = min(ans, (c[u+k-1]-a[i-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 | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 292 KB | Output is correct |
4 | Correct | 0 ms | 288 KB | Output is correct |
5 | Correct | 0 ms | 292 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 292 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 0 ms | 288 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 292 KB | Output is correct |
4 | Correct | 0 ms | 288 KB | Output is correct |
5 | Correct | 0 ms | 292 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 292 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 0 ms | 288 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 280 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 0 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 292 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 284 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 0 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 | 292 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 0 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 204 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 280 KB | Output is correct |
33 | Correct | 1 ms | 316 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 | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 292 KB | Output is correct |
4 | Correct | 0 ms | 288 KB | Output is correct |
5 | Correct | 0 ms | 292 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 292 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 0 ms | 288 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 280 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 0 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 292 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 284 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 0 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 | 292 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 0 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 204 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 280 KB | Output is correct |
33 | Correct | 1 ms | 316 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 12 ms | 1456 KB | Output is correct |
37 | Correct | 13 ms | 1812 KB | Output is correct |
38 | Correct | 13 ms | 1956 KB | Output is correct |
39 | Correct | 12 ms | 1956 KB | Output is correct |
40 | Correct | 9 ms | 2000 KB | Output is correct |
41 | Correct | 11 ms | 1932 KB | Output is correct |
42 | Correct | 13 ms | 1824 KB | Output is correct |
43 | Correct | 5 ms | 1336 KB | Output is correct |
44 | Correct | 6 ms | 1460 KB | Output is correct |
45 | Correct | 7 ms | 2004 KB | Output is correct |
46 | Correct | 7 ms | 1964 KB | Output is correct |
47 | Correct | 8 ms | 1996 KB | Output is correct |
48 | Correct | 8 ms | 1976 KB | Output is correct |
49 | Correct | 5 ms | 1268 KB | Output is correct |
50 | Correct | 7 ms | 1752 KB | Output is correct |
51 | Correct | 7 ms | 1712 KB | Output is correct |
52 | Correct | 7 ms | 1488 KB | Output is correct |
53 | Correct | 7 ms | 1736 KB | Output is correct |
54 | Correct | 7 ms | 1972 KB | Output is correct |
55 | Correct | 6 ms | 1980 KB | Output is correct |
56 | Correct | 6 ms | 1972 KB | Output is correct |