# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233712 | 2020-05-21T13:28:55 Z | duality | JJOOII 2 (JOI20_ho_t2) | C++11 | 28 ms | 5504 KB |
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vpii; char S[200000]; int pre[3][200001],n[3][200001]; int main() { int i,j; int N,K; scanf("%d %d",&N,&K); for (i = 0; i < N; i++) { scanf(" %c",&S[i]); for (j = 0; j < 3; j++) pre[j][i+1] = pre[j][i]; if (S[i] == 'J') pre[0][i+1]++; else if (S[i] == 'O') pre[1][i+1]++; else pre[2][i+1]++; } int ans = 1e9; j = 0; for (i = 0; i < N; i++) { while (pre[0][i+1]-pre[0][j] >= K) j++; n[0][i] = j-1; } j = 0; for (i = 0; i < N; i++) { while (pre[1][i+1]-pre[1][j] >= K) j++; n[1][i] = j-1; } j = 0; for (i = 0; i < N; i++) { while (pre[2][i+1]-pre[2][j] >= K) j++; n[2][i] = j-1; } for (i = 0; i < N; i++) { int u = n[2][i]-1; if (u >= 0) u = n[1][u]-1; else u = -2; if (u >= 0) u = n[0][u]-1; else u = -2; if (u != -2) ans = min(ans,i-u); } if (ans == 1e9) printf("-1\n"); else printf("%d\n",ans-3*K); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 4 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 | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 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 | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 4 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 | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 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 | 512 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 512 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 | 512 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 5 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 | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 4 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 | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 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 | 512 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 512 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 | 512 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 5 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 | 23 ms | 5120 KB | Output is correct |
37 | Correct | 25 ms | 5376 KB | Output is correct |
38 | Correct | 25 ms | 5376 KB | Output is correct |
39 | Correct | 26 ms | 5376 KB | Output is correct |
40 | Correct | 25 ms | 5504 KB | Output is correct |
41 | Correct | 25 ms | 5376 KB | Output is correct |
42 | Correct | 26 ms | 5372 KB | Output is correct |
43 | Correct | 17 ms | 3456 KB | Output is correct |
44 | Correct | 22 ms | 4224 KB | Output is correct |
45 | Correct | 28 ms | 5368 KB | Output is correct |
46 | Correct | 24 ms | 5376 KB | Output is correct |
47 | Correct | 24 ms | 5376 KB | Output is correct |
48 | Correct | 24 ms | 5376 KB | Output is correct |
49 | Correct | 18 ms | 3712 KB | Output is correct |
50 | Correct | 24 ms | 5376 KB | Output is correct |
51 | Correct | 24 ms | 5376 KB | Output is correct |
52 | Correct | 21 ms | 5248 KB | Output is correct |
53 | Correct | 21 ms | 5376 KB | Output is correct |
54 | Correct | 20 ms | 5376 KB | Output is correct |
55 | Correct | 19 ms | 5376 KB | Output is correct |
56 | Correct | 20 ms | 5376 KB | Output is correct |