# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201272 | 2020-02-10T05:49:13 Z | arnold518 | JJOOII 2 (JOI20_ho_t2) | C++14 | 32 ms | 1780 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3e5; const int INF = 987654321; int N, K, ans=INF; char S[MAXN+10]; vector<int> J, O, I; int main() { int i, j; scanf("%d%d%s", &N, &K, S+1); for(i=1; i<=N; i++) { if(S[i]=='J') J.push_back(i); else if(S[i]=='O') O.push_back(i); else I.push_back(i); int val=N+10, it; it=lower_bound(I.begin(), I.end(), val)-I.begin()-K; if(it<0) continue; val=I[it]; it=lower_bound(O.begin(), O.end(), val)-O.begin()-K; if(it<0) continue; val=O[it]; it=lower_bound(J.begin(), J.end(), val)-J.begin()-K; if(it<0) continue; val=J[it]; ans=min(ans, i-val+1-3*K); } if(ans==INF) ans=-1; printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 280 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 280 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 300 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 376 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 280 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 300 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 376 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 380 KB | Output is correct |
36 | Correct | 27 ms | 1396 KB | Output is correct |
37 | Correct | 30 ms | 1772 KB | Output is correct |
38 | Correct | 32 ms | 1652 KB | Output is correct |
39 | Correct | 29 ms | 1780 KB | Output is correct |
40 | Correct | 23 ms | 1648 KB | Output is correct |
41 | Correct | 26 ms | 1648 KB | Output is correct |
42 | Correct | 28 ms | 1652 KB | Output is correct |
43 | Correct | 15 ms | 1144 KB | Output is correct |
44 | Correct | 18 ms | 1256 KB | Output is correct |
45 | Correct | 28 ms | 1652 KB | Output is correct |
46 | Correct | 22 ms | 1616 KB | Output is correct |
47 | Correct | 23 ms | 1772 KB | Output is correct |
48 | Correct | 21 ms | 1780 KB | Output is correct |
49 | Correct | 16 ms | 1272 KB | Output is correct |
50 | Correct | 22 ms | 1648 KB | Output is correct |
51 | Correct | 22 ms | 1652 KB | Output is correct |
52 | Correct | 14 ms | 1396 KB | Output is correct |
53 | Correct | 15 ms | 1652 KB | Output is correct |
54 | Correct | 14 ms | 1776 KB | Output is correct |
55 | Correct | 10 ms | 1776 KB | Output is correct |
56 | Correct | 9 ms | 1776 KB | Output is correct |