# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
296803 | 2020-09-10T22:06:33 Z | Bruteforceman | JJOOII 2 (JOI20_ho_t2) | C++11 | 18 ms | 3344 KB |
#include "bits/stdc++.h" using namespace std; const int inf = 1e9; string s; vector <int> solve(char c, int k) { vector <int> v (s.size()); int r = 0; int cnt = 0; for(int i = 0; i < s.size(); i++) { while(r < s.size() && cnt < k) { cnt += (s[r] == c); ++r; } v[i] = (cnt == k) ? r : inf; cnt -= (s[i] == c); } return v; } int main(int argc, char const *argv[]) { int n, k; cin >> n >> k; cin >> s; map <char, int> cnt; int r = 0; int ans = inf; vector <int> a[3]; a[0] = solve('J', k); a[1] = solve('O', k); a[2] = solve('I', k); for(int i = 0; i < n; i++) { int cur = i; for(int j = 0; j < 3; j++) { if(cur >= s.size()) { cur = inf; break; } cur = a[j][cur]; } ans = min(ans, cur - i - 3 * k); } if(ans > n) ans = -1; cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 328 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 328 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 328 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 15 ms | 3088 KB | Output is correct |
37 | Correct | 18 ms | 3216 KB | Output is correct |
38 | Correct | 16 ms | 3216 KB | Output is correct |
39 | Correct | 18 ms | 3216 KB | Output is correct |
40 | Correct | 18 ms | 3216 KB | Output is correct |
41 | Correct | 18 ms | 3216 KB | Output is correct |
42 | Correct | 18 ms | 3216 KB | Output is correct |
43 | Correct | 11 ms | 2192 KB | Output is correct |
44 | Correct | 13 ms | 2576 KB | Output is correct |
45 | Correct | 17 ms | 3216 KB | Output is correct |
46 | Correct | 17 ms | 3344 KB | Output is correct |
47 | Correct | 16 ms | 3216 KB | Output is correct |
48 | Correct | 16 ms | 3216 KB | Output is correct |
49 | Correct | 12 ms | 2332 KB | Output is correct |
50 | Correct | 17 ms | 3216 KB | Output is correct |
51 | Correct | 16 ms | 3216 KB | Output is correct |
52 | Correct | 14 ms | 3088 KB | Output is correct |
53 | Correct | 14 ms | 3248 KB | Output is correct |
54 | Correct | 14 ms | 3216 KB | Output is correct |
55 | Correct | 13 ms | 3216 KB | Output is correct |
56 | Correct | 13 ms | 3216 KB | Output is correct |