# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
747685 | 2023-05-24T13:21:00 Z | Sami_Massah | JJOOII 2 (JOI20_ho_t2) | C++17 | 16 ms | 3556 KB |
#include <bits/stdc++.h> using namespace std; const long long maxn = 3e5 + 12, mod = 1e9 + 7, inf = 1e9 + 12 ; long long n, k, cnt[maxn]; vector<int> locs[3]; string s; int main(){ cin >> n >> k; cin >> s; cnt[1] = (s[0] == 'O'); for(int i = 1; i < n; i++) if(s[i] == 'O') cnt[i] = cnt[i - 1] + 1; else cnt[i] = cnt[i - 1]; for(int i = 0; i < n; i++) if(s[i] == 'J') locs[0].push_back(i); else if(s[i] == 'O') locs[1].push_back(i); else locs[2].push_back(i); long long ans = maxn; for(int loc = 0; loc + k - 1 < locs[0].size(); loc++){ int ne = locs[0][loc + k - 1]; int l = -1, r = locs[2].size() - k + 1, mid; while(r - l != 1){ int mid = (l + r) / 2; if(cnt[locs[2][mid]] - cnt[ne] >= k) r = mid; else l = mid; } if(r != locs[2].size() - k + 1) ans = min(ans, locs[2][r + k - 1] - locs[0][loc] + 1 - k * 3); } if(ans == maxn) ans = -1; cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 14 ms | 2732 KB | Output is correct |
37 | Correct | 16 ms | 3336 KB | Output is correct |
38 | Correct | 15 ms | 3488 KB | Output is correct |
39 | Correct | 15 ms | 3504 KB | Output is correct |
40 | Correct | 13 ms | 3556 KB | Output is correct |
41 | Correct | 16 ms | 3484 KB | Output is correct |
42 | Correct | 15 ms | 3364 KB | Output is correct |
43 | Correct | 8 ms | 2244 KB | Output is correct |
44 | Correct | 10 ms | 2612 KB | Output is correct |
45 | Correct | 12 ms | 3528 KB | Output is correct |
46 | Correct | 13 ms | 3536 KB | Output is correct |
47 | Correct | 12 ms | 3544 KB | Output is correct |
48 | Correct | 13 ms | 3552 KB | Output is correct |
49 | Correct | 9 ms | 2388 KB | Output is correct |
50 | Correct | 13 ms | 3408 KB | Output is correct |
51 | Correct | 12 ms | 3292 KB | Output is correct |
52 | Correct | 8 ms | 3032 KB | Output is correct |
53 | Correct | 9 ms | 3276 KB | Output is correct |
54 | Correct | 14 ms | 3552 KB | Output is correct |
55 | Correct | 9 ms | 3536 KB | Output is correct |
56 | Correct | 7 ms | 3552 KB | Output is correct |