# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
649590 | 2022-10-10T22:25:59 Z | inwbear | JJOOII 2 (JOI20_ho_t2) | C++14 | 7 ms | 2000 KB |
#include<bits/stdc++.h> using namespace std; int n,k,ans=INT_MAX,mid_size; char c[200005]; vector<int>pos[3]; int cur[3]; int main(){ scanf("%d %d",&n,&k); scanf("%s",c+1); //hashing the position of each character for(int i=1;i<=n;i++){ if(c[i] == 'J')pos[0].push_back(i); else if(c[i] == 'O')pos[1].push_back(i); else pos[2].push_back(i); } //brute-force for all possible x for(int i = 1; i <= n; i++){ while(cur[0] < pos[0].size()){ if(pos[0][cur[0]] >= i)break; cur[0]++; } if(cur[0]+k-1 >= pos[0].size())break; while(cur[1] < pos[1].size()){ if(pos[1][cur[1]] >= pos[0][cur[0]+k-1])break; cur[1]++; } if(cur[1]+k-1 >= pos[1].size())break; while(cur[2] < pos[2].size()){ if(pos[2][cur[2]] >= pos[1][cur[1]+k-1])break; cur[2]++; } if(cur[2]+k-1 >= pos[2].size())break; mid_size = pos[2][cur[2]+k-1] - i + 1; ans=min(ans, mid_size - (3 * k)); } if(ans==INT_MAX)printf("-1"); else printf("%d",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 304 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 | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 304 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 | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 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 | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 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 | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 312 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 304 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 | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 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 | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 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 | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 312 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 6 ms | 1488 KB | Output is correct |
37 | Correct | 7 ms | 1816 KB | Output is correct |
38 | Correct | 7 ms | 1964 KB | Output is correct |
39 | Correct | 7 ms | 1976 KB | Output is correct |
40 | Correct | 4 ms | 1832 KB | Output is correct |
41 | Correct | 5 ms | 1872 KB | Output is correct |
42 | Correct | 6 ms | 1856 KB | Output is correct |
43 | Correct | 3 ms | 1220 KB | Output is correct |
44 | Correct | 3 ms | 1348 KB | Output is correct |
45 | Correct | 4 ms | 2000 KB | Output is correct |
46 | Correct | 4 ms | 1868 KB | Output is correct |
47 | Correct | 4 ms | 1856 KB | Output is correct |
48 | Correct | 4 ms | 2000 KB | Output is correct |
49 | Correct | 3 ms | 1316 KB | Output is correct |
50 | Correct | 5 ms | 1872 KB | Output is correct |
51 | Correct | 4 ms | 1876 KB | Output is correct |
52 | Correct | 4 ms | 1472 KB | Output is correct |
53 | Correct | 4 ms | 1796 KB | Output is correct |
54 | Correct | 3 ms | 2000 KB | Output is correct |
55 | Correct | 3 ms | 2000 KB | Output is correct |
56 | Correct | 2 ms | 1980 KB | Output is correct |