# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
273017 | 2020-08-19T01:28:55 Z | ChrisT | JJOOII 2 (JOI20_ho_t2) | C++17 | 31 ms | 2048 KB |
#include <bits/stdc++.h> using namespace std; char s[200'005]; int main() { int n,k; scanf ("%d %d",&n,&k); scanf ("%s",s+1); vector<int> js,os,is; for (int i = 1; i <= n; i++) { if (s[i] == 'J') js.push_back(i); else if (s[i] == 'O') os.push_back(i); else is.push_back(i); } int ret = 1e9; for (int i = 1; i <= n; i++) { int needJ = lower_bound(js.begin(),js.end(),i) - js.begin(); needJ += k-1; if (needJ < (int)js.size()) { int pos = js[needJ]; int needO = lower_bound(os.begin(),os.end(),pos) - os.begin(); needO += k-1; if (needO < (int)os.size()) { pos = os[needO]; int needI = lower_bound(is.begin(),is.end(),pos) - is.begin(); needI += k-1; if (needI < (int)is.size()) { pos = is[needI]; ret = min(ret,n - (i-1) - (n-pos) - k*3); } } } } printf ("%d\n",ret<1e9?ret:-1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 368 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 368 KB | Output is correct |
14 | Correct | 1 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 | 376 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 | 288 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 | 372 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 368 KB | Output is correct |
14 | Correct | 1 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 | 376 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 | 288 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 | 372 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 25 ms | 1532 KB | Output is correct |
37 | Correct | 28 ms | 1916 KB | Output is correct |
38 | Correct | 31 ms | 1916 KB | Output is correct |
39 | Correct | 25 ms | 2044 KB | Output is correct |
40 | Correct | 21 ms | 1916 KB | Output is correct |
41 | Correct | 24 ms | 1916 KB | Output is correct |
42 | Correct | 27 ms | 1916 KB | Output is correct |
43 | Correct | 13 ms | 1276 KB | Output is correct |
44 | Correct | 15 ms | 1384 KB | Output is correct |
45 | Correct | 20 ms | 1912 KB | Output is correct |
46 | Correct | 20 ms | 1908 KB | Output is correct |
47 | Correct | 26 ms | 1916 KB | Output is correct |
48 | Correct | 20 ms | 2044 KB | Output is correct |
49 | Correct | 15 ms | 1408 KB | Output is correct |
50 | Correct | 20 ms | 1916 KB | Output is correct |
51 | Correct | 20 ms | 2048 KB | Output is correct |
52 | Correct | 13 ms | 1532 KB | Output is correct |
53 | Correct | 14 ms | 1916 KB | Output is correct |
54 | Correct | 13 ms | 2040 KB | Output is correct |
55 | Correct | 10 ms | 2040 KB | Output is correct |
56 | Correct | 10 ms | 2040 KB | Output is correct |