# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557250 | 2022-05-05T04:46:02 Z | krit3379 | JJOOII 2 (JOI20_ho_t2) | C++17 | 11 ms | 1996 KB |
#include<bits/stdc++.h> using namespace std; #define N 200005 int nxt,ans=1e9; char s[N]; vector<int> v[4]; int main(){ int n,k,i; scanf("%d %d %s",&n,&k,s+1); for(i=1;i<=n;i++){ if(s[i]=='J')v[1].push_back(i); else if(s[i]=='O')v[2].push_back(i); else v[3].push_back(i); } for(i=0;i<v[1].size();i++){ nxt=i+k-1; if(nxt>=v[1].size())break; nxt=lower_bound(v[2].begin(),v[2].end(),v[1][nxt])-v[2].begin()+k-1; if(nxt>=v[2].size())break; nxt=lower_bound(v[3].begin(),v[3].end(),v[2][nxt])-v[3].begin()+k-1; if(nxt>=v[3].size())break; ans=min(ans,v[3][nxt]-v[1][i]+1-3*k); } if(ans==1e9)printf("-1"); else printf("%d",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 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 | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 308 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 | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 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 | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 308 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 | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 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 | 340 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 | 304 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 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 | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 308 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 | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 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 | 340 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 | 304 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 9 ms | 1488 KB | Output is correct |
37 | Correct | 10 ms | 1808 KB | Output is correct |
38 | Correct | 10 ms | 1932 KB | Output is correct |
39 | Correct | 9 ms | 1956 KB | Output is correct |
40 | Correct | 5 ms | 1772 KB | Output is correct |
41 | Correct | 8 ms | 1872 KB | Output is correct |
42 | Correct | 11 ms | 1876 KB | Output is correct |
43 | Correct | 3 ms | 1236 KB | Output is correct |
44 | Correct | 4 ms | 1364 KB | Output is correct |
45 | Correct | 4 ms | 1984 KB | Output is correct |
46 | Correct | 4 ms | 1868 KB | Output is correct |
47 | Correct | 4 ms | 1856 KB | Output is correct |
48 | Correct | 5 ms | 1980 KB | Output is correct |
49 | Correct | 3 ms | 1360 KB | Output is correct |
50 | Correct | 4 ms | 1840 KB | Output is correct |
51 | Correct | 5 ms | 1852 KB | Output is correct |
52 | Correct | 3 ms | 1488 KB | Output is correct |
53 | Correct | 4 ms | 1876 KB | Output is correct |
54 | Correct | 4 ms | 1884 KB | Output is correct |
55 | Correct | 3 ms | 1996 KB | Output is correct |
56 | Correct | 3 ms | 1888 KB | Output is correct |