# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438876 | 2021-06-28T21:23:05 Z | Snowfall | JJOOII 2 (JOI20_ho_t2) | C++14 | 35 ms | 3040 KB |
#include<bits/stdc++.h> using namespace std; char arr[200005]; int a[1000]; int qs[3][200005]; main() { int t,p; a['O']=1; a['I']=2; scanf("%d%d",&t,&p); scanf("%s",&arr[1]); for(int i = 1;i <= t;i++) { qs[a[arr[i]]][i]++; // printf("%d\n",arr[i]); for(int j = 0;j < 3;j++) qs[j][i]+=qs[j][i-1]; } int mn=1e9; for(int i = 1;i <= t;i++) { int ck=0; int pv=i; int sm=0; for(int j = 0;j < 3 && ck==j;j++) { int st=pv,ed=t; int tmn=1e9; while(st<=ed) { int md=(st+ed)/2; // printf("%d %d<--\n",qs[j][md],qs[j][pv-1]); if(qs[j][md]-qs[j][pv-1]>=p) { ed=md-1; tmn=min(tmn,md); } else { st=md+1; } } // printf("d %d %d %d\n",j,tmn,pv-1); if(tmn==1e9) break; if(qs[j][tmn]-qs[j][pv-1]==p) { sm+=tmn-pv+1-p; ck++; pv=tmn+1; } // printf("%d %d\n",pv,sm); } if(ck==3) mn=min(mn,sm); } if(mn!=1e9) printf("%d",mn); else printf("-1"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 356 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 304 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 300 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 280 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 356 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 304 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 300 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 280 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 29 ms | 2764 KB | Output is correct |
37 | Correct | 31 ms | 3020 KB | Output is correct |
38 | Correct | 31 ms | 3028 KB | Output is correct |
39 | Correct | 31 ms | 3020 KB | Output is correct |
40 | Correct | 24 ms | 3020 KB | Output is correct |
41 | Correct | 30 ms | 3032 KB | Output is correct |
42 | Correct | 35 ms | 3020 KB | Output is correct |
43 | Correct | 12 ms | 2020 KB | Output is correct |
44 | Correct | 17 ms | 2364 KB | Output is correct |
45 | Correct | 20 ms | 2996 KB | Output is correct |
46 | Correct | 20 ms | 3020 KB | Output is correct |
47 | Correct | 20 ms | 3032 KB | Output is correct |
48 | Correct | 19 ms | 3020 KB | Output is correct |
49 | Correct | 13 ms | 2124 KB | Output is correct |
50 | Correct | 20 ms | 3020 KB | Output is correct |
51 | Correct | 20 ms | 3020 KB | Output is correct |
52 | Correct | 10 ms | 2892 KB | Output is correct |
53 | Correct | 11 ms | 3020 KB | Output is correct |
54 | Correct | 16 ms | 3040 KB | Output is correct |
55 | Correct | 13 ms | 3020 KB | Output is correct |
56 | Correct | 9 ms | 3036 KB | Output is correct |