# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217955 | 2020-03-31T10:29:13 Z | KoalaMuch | JJOOII 2 (JOI20_ho_t2) | C++14 | 32 ms | 3088 KB |
#include<bits/stdc++.h> using namespace std; const int N = 2e5+5; int dp[N][3]; char s[N]; int get(char c) { if(c=='J') return 0; else if(c=='O') return 1; return 2; } int main() { int n,k; int ans = 1e9; scanf("%d %d %s",&n,&k,s+1); for(int i=1;i<=n;i++) { dp[i][get(s[i])]++; for(int j=0;j<3;j++) dp[i][j]+=dp[i-1][j]; } for(int i=1;i<=n;i++) { int cur = i,l = i,r = n+1; while(l<r) { int mid = (l+r) >> 1; if(dp[mid][0]-dp[cur-1][0]<k) l=mid+1; else r=mid; } if(l==n+1) continue; cur = l+1,l = cur,r = n+1; while(l<r) { int mid = (l+r) >> 1; if(dp[mid][1]-dp[cur-1][1]<k) l=mid+1; else r=mid; } if(l==n+1) continue; cur = l+1,l = cur,r = n+1; while(l<r) { int mid = (l+r) >> 1; if(dp[mid][2]-dp[cur-1][2]<k) l=mid+1; else r=mid; } if(l==n+1) continue; ans = min(ans,l-i+1-3*k); } printf(ans==1e9 ? "-1\n" : "%d\n",ans); return 0; } /* 10 2 JJOOJJOOII 10 2 JJIIJJOOII */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 4 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 4 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 25 ms | 2816 KB | Output is correct |
37 | Correct | 27 ms | 3072 KB | Output is correct |
38 | Correct | 27 ms | 3072 KB | Output is correct |
39 | Correct | 32 ms | 3072 KB | Output is correct |
40 | Correct | 25 ms | 3072 KB | Output is correct |
41 | Correct | 30 ms | 3088 KB | Output is correct |
42 | Correct | 32 ms | 3072 KB | Output is correct |
43 | Correct | 15 ms | 2048 KB | Output is correct |
44 | Correct | 19 ms | 2432 KB | Output is correct |
45 | Correct | 26 ms | 3072 KB | Output is correct |
46 | Correct | 23 ms | 3072 KB | Output is correct |
47 | Correct | 23 ms | 3072 KB | Output is correct |
48 | Correct | 22 ms | 3072 KB | Output is correct |
49 | Correct | 17 ms | 2176 KB | Output is correct |
50 | Correct | 22 ms | 3072 KB | Output is correct |
51 | Correct | 22 ms | 3072 KB | Output is correct |
52 | Correct | 14 ms | 2944 KB | Output is correct |
53 | Correct | 15 ms | 3072 KB | Output is correct |
54 | Correct | 19 ms | 3072 KB | Output is correct |
55 | Correct | 15 ms | 3072 KB | Output is correct |
56 | Correct | 13 ms | 3072 KB | Output is correct |