# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205670 | 2020-02-29T12:11:55 Z | Kastanda | Rope (JOI17_rope) | C++11 | 1523 ms | 139492 KB |
// In The Name Of The Queen #include<bits/stdc++.h> #define x first #define y second using namespace std; const int N = 1000006; int n, m, A[N], C[N], S[N * 2]; vector < int > V[N][2]; inline void Add(int i, int val) { S[i += m - 1] += val; for (; i; i >>= 1) S[i >> 1] = max(S[i], S[i ^ 1]); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i ++) scanf("%d", &A[i]); for (int i = 1; i <= n; i ++) { C[A[i]] ++; for (int j = 0; j <= 1; j ++) { int nxt = i + 1 - ((i + j) % 2) * 2; if (A[nxt] && A[nxt] != A[i]) V[A[i]][j].push_back(A[nxt]); } Add(A[i], 1); } for (int c = 1; c <= m; c ++) { int Mn = n - C[c]; Add(c, -C[c]); for (int j = 0; j <= 1; j ++) { for (int a : V[c][j]) Add(a, -1); Mn = min(Mn, n - C[c] - S[1]); for (int a : V[c][j]) Add(a, 1); } Add(c, C[c]); printf("%d\n", Mn); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 47352 KB | Output is correct |
2 | Correct | 33 ms | 47352 KB | Output is correct |
3 | Correct | 32 ms | 47352 KB | Output is correct |
4 | Correct | 32 ms | 47224 KB | Output is correct |
5 | Correct | 33 ms | 47352 KB | Output is correct |
6 | Correct | 32 ms | 47480 KB | Output is correct |
7 | Correct | 32 ms | 47352 KB | Output is correct |
8 | Correct | 32 ms | 47224 KB | Output is correct |
9 | Correct | 33 ms | 47352 KB | Output is correct |
10 | Correct | 32 ms | 47352 KB | Output is correct |
11 | Correct | 33 ms | 47352 KB | Output is correct |
12 | Correct | 32 ms | 47352 KB | Output is correct |
13 | Correct | 34 ms | 47352 KB | Output is correct |
14 | Correct | 32 ms | 47352 KB | Output is correct |
15 | Correct | 33 ms | 47352 KB | Output is correct |
16 | Correct | 33 ms | 47352 KB | Output is correct |
17 | Correct | 33 ms | 47352 KB | Output is correct |
18 | Correct | 32 ms | 47352 KB | Output is correct |
19 | Correct | 32 ms | 47352 KB | Output is correct |
20 | Correct | 33 ms | 47352 KB | Output is correct |
21 | Correct | 33 ms | 47352 KB | Output is correct |
22 | Correct | 34 ms | 47352 KB | Output is correct |
23 | Correct | 32 ms | 47352 KB | Output is correct |
24 | Correct | 33 ms | 47352 KB | Output is correct |
25 | Correct | 36 ms | 47352 KB | Output is correct |
26 | Correct | 34 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 47352 KB | Output is correct |
2 | Correct | 33 ms | 47352 KB | Output is correct |
3 | Correct | 32 ms | 47352 KB | Output is correct |
4 | Correct | 32 ms | 47224 KB | Output is correct |
5 | Correct | 33 ms | 47352 KB | Output is correct |
6 | Correct | 32 ms | 47480 KB | Output is correct |
7 | Correct | 32 ms | 47352 KB | Output is correct |
8 | Correct | 32 ms | 47224 KB | Output is correct |
9 | Correct | 33 ms | 47352 KB | Output is correct |
10 | Correct | 32 ms | 47352 KB | Output is correct |
11 | Correct | 33 ms | 47352 KB | Output is correct |
12 | Correct | 32 ms | 47352 KB | Output is correct |
13 | Correct | 34 ms | 47352 KB | Output is correct |
14 | Correct | 32 ms | 47352 KB | Output is correct |
15 | Correct | 33 ms | 47352 KB | Output is correct |
16 | Correct | 33 ms | 47352 KB | Output is correct |
17 | Correct | 33 ms | 47352 KB | Output is correct |
18 | Correct | 32 ms | 47352 KB | Output is correct |
19 | Correct | 32 ms | 47352 KB | Output is correct |
20 | Correct | 33 ms | 47352 KB | Output is correct |
21 | Correct | 33 ms | 47352 KB | Output is correct |
22 | Correct | 34 ms | 47352 KB | Output is correct |
23 | Correct | 32 ms | 47352 KB | Output is correct |
24 | Correct | 33 ms | 47352 KB | Output is correct |
25 | Correct | 36 ms | 47352 KB | Output is correct |
26 | Correct | 34 ms | 47352 KB | Output is correct |
27 | Correct | 50 ms | 48888 KB | Output is correct |
28 | Correct | 47 ms | 48632 KB | Output is correct |
29 | Correct | 50 ms | 48760 KB | Output is correct |
30 | Correct | 49 ms | 48504 KB | Output is correct |
31 | Correct | 51 ms | 48760 KB | Output is correct |
32 | Correct | 49 ms | 48632 KB | Output is correct |
33 | Correct | 51 ms | 48760 KB | Output is correct |
34 | Correct | 49 ms | 48504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 47352 KB | Output is correct |
2 | Correct | 33 ms | 47352 KB | Output is correct |
3 | Correct | 32 ms | 47352 KB | Output is correct |
4 | Correct | 32 ms | 47224 KB | Output is correct |
5 | Correct | 33 ms | 47352 KB | Output is correct |
6 | Correct | 32 ms | 47480 KB | Output is correct |
7 | Correct | 32 ms | 47352 KB | Output is correct |
8 | Correct | 32 ms | 47224 KB | Output is correct |
9 | Correct | 33 ms | 47352 KB | Output is correct |
10 | Correct | 32 ms | 47352 KB | Output is correct |
11 | Correct | 33 ms | 47352 KB | Output is correct |
12 | Correct | 32 ms | 47352 KB | Output is correct |
13 | Correct | 34 ms | 47352 KB | Output is correct |
14 | Correct | 32 ms | 47352 KB | Output is correct |
15 | Correct | 33 ms | 47352 KB | Output is correct |
16 | Correct | 33 ms | 47352 KB | Output is correct |
17 | Correct | 33 ms | 47352 KB | Output is correct |
18 | Correct | 32 ms | 47352 KB | Output is correct |
19 | Correct | 32 ms | 47352 KB | Output is correct |
20 | Correct | 33 ms | 47352 KB | Output is correct |
21 | Correct | 33 ms | 47352 KB | Output is correct |
22 | Correct | 34 ms | 47352 KB | Output is correct |
23 | Correct | 32 ms | 47352 KB | Output is correct |
24 | Correct | 33 ms | 47352 KB | Output is correct |
25 | Correct | 36 ms | 47352 KB | Output is correct |
26 | Correct | 34 ms | 47352 KB | Output is correct |
27 | Correct | 50 ms | 48888 KB | Output is correct |
28 | Correct | 47 ms | 48632 KB | Output is correct |
29 | Correct | 50 ms | 48760 KB | Output is correct |
30 | Correct | 49 ms | 48504 KB | Output is correct |
31 | Correct | 51 ms | 48760 KB | Output is correct |
32 | Correct | 49 ms | 48632 KB | Output is correct |
33 | Correct | 51 ms | 48760 KB | Output is correct |
34 | Correct | 49 ms | 48504 KB | Output is correct |
35 | Correct | 56 ms | 48888 KB | Output is correct |
36 | Correct | 57 ms | 49144 KB | Output is correct |
37 | Correct | 60 ms | 49144 KB | Output is correct |
38 | Correct | 56 ms | 49148 KB | Output is correct |
39 | Correct | 61 ms | 49280 KB | Output is correct |
40 | Correct | 56 ms | 49400 KB | Output is correct |
41 | Correct | 56 ms | 49400 KB | Output is correct |
42 | Correct | 57 ms | 49400 KB | Output is correct |
43 | Correct | 58 ms | 49400 KB | Output is correct |
44 | Correct | 59 ms | 49400 KB | Output is correct |
45 | Correct | 57 ms | 49400 KB | Output is correct |
46 | Correct | 57 ms | 49272 KB | Output is correct |
47 | Correct | 56 ms | 49400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 47352 KB | Output is correct |
2 | Correct | 33 ms | 47352 KB | Output is correct |
3 | Correct | 32 ms | 47352 KB | Output is correct |
4 | Correct | 32 ms | 47224 KB | Output is correct |
5 | Correct | 33 ms | 47352 KB | Output is correct |
6 | Correct | 32 ms | 47480 KB | Output is correct |
7 | Correct | 32 ms | 47352 KB | Output is correct |
8 | Correct | 32 ms | 47224 KB | Output is correct |
9 | Correct | 33 ms | 47352 KB | Output is correct |
10 | Correct | 32 ms | 47352 KB | Output is correct |
11 | Correct | 33 ms | 47352 KB | Output is correct |
12 | Correct | 32 ms | 47352 KB | Output is correct |
13 | Correct | 34 ms | 47352 KB | Output is correct |
14 | Correct | 32 ms | 47352 KB | Output is correct |
15 | Correct | 33 ms | 47352 KB | Output is correct |
16 | Correct | 33 ms | 47352 KB | Output is correct |
17 | Correct | 33 ms | 47352 KB | Output is correct |
18 | Correct | 32 ms | 47352 KB | Output is correct |
19 | Correct | 32 ms | 47352 KB | Output is correct |
20 | Correct | 33 ms | 47352 KB | Output is correct |
21 | Correct | 33 ms | 47352 KB | Output is correct |
22 | Correct | 34 ms | 47352 KB | Output is correct |
23 | Correct | 32 ms | 47352 KB | Output is correct |
24 | Correct | 33 ms | 47352 KB | Output is correct |
25 | Correct | 36 ms | 47352 KB | Output is correct |
26 | Correct | 34 ms | 47352 KB | Output is correct |
27 | Correct | 50 ms | 48888 KB | Output is correct |
28 | Correct | 47 ms | 48632 KB | Output is correct |
29 | Correct | 50 ms | 48760 KB | Output is correct |
30 | Correct | 49 ms | 48504 KB | Output is correct |
31 | Correct | 51 ms | 48760 KB | Output is correct |
32 | Correct | 49 ms | 48632 KB | Output is correct |
33 | Correct | 51 ms | 48760 KB | Output is correct |
34 | Correct | 49 ms | 48504 KB | Output is correct |
35 | Correct | 56 ms | 48888 KB | Output is correct |
36 | Correct | 57 ms | 49144 KB | Output is correct |
37 | Correct | 60 ms | 49144 KB | Output is correct |
38 | Correct | 56 ms | 49148 KB | Output is correct |
39 | Correct | 61 ms | 49280 KB | Output is correct |
40 | Correct | 56 ms | 49400 KB | Output is correct |
41 | Correct | 56 ms | 49400 KB | Output is correct |
42 | Correct | 57 ms | 49400 KB | Output is correct |
43 | Correct | 58 ms | 49400 KB | Output is correct |
44 | Correct | 59 ms | 49400 KB | Output is correct |
45 | Correct | 57 ms | 49400 KB | Output is correct |
46 | Correct | 57 ms | 49272 KB | Output is correct |
47 | Correct | 56 ms | 49400 KB | Output is correct |
48 | Correct | 326 ms | 68984 KB | Output is correct |
49 | Correct | 335 ms | 69112 KB | Output is correct |
50 | Correct | 340 ms | 69112 KB | Output is correct |
51 | Correct | 315 ms | 68600 KB | Output is correct |
52 | Correct | 288 ms | 66040 KB | Output is correct |
53 | Correct | 315 ms | 67448 KB | Output is correct |
54 | Correct | 305 ms | 65528 KB | Output is correct |
55 | Correct | 318 ms | 65144 KB | Output is correct |
56 | Correct | 305 ms | 64504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 47352 KB | Output is correct |
2 | Correct | 33 ms | 47352 KB | Output is correct |
3 | Correct | 32 ms | 47352 KB | Output is correct |
4 | Correct | 32 ms | 47224 KB | Output is correct |
5 | Correct | 33 ms | 47352 KB | Output is correct |
6 | Correct | 32 ms | 47480 KB | Output is correct |
7 | Correct | 32 ms | 47352 KB | Output is correct |
8 | Correct | 32 ms | 47224 KB | Output is correct |
9 | Correct | 33 ms | 47352 KB | Output is correct |
10 | Correct | 32 ms | 47352 KB | Output is correct |
11 | Correct | 33 ms | 47352 KB | Output is correct |
12 | Correct | 32 ms | 47352 KB | Output is correct |
13 | Correct | 34 ms | 47352 KB | Output is correct |
14 | Correct | 32 ms | 47352 KB | Output is correct |
15 | Correct | 33 ms | 47352 KB | Output is correct |
16 | Correct | 33 ms | 47352 KB | Output is correct |
17 | Correct | 33 ms | 47352 KB | Output is correct |
18 | Correct | 32 ms | 47352 KB | Output is correct |
19 | Correct | 32 ms | 47352 KB | Output is correct |
20 | Correct | 33 ms | 47352 KB | Output is correct |
21 | Correct | 33 ms | 47352 KB | Output is correct |
22 | Correct | 34 ms | 47352 KB | Output is correct |
23 | Correct | 32 ms | 47352 KB | Output is correct |
24 | Correct | 33 ms | 47352 KB | Output is correct |
25 | Correct | 36 ms | 47352 KB | Output is correct |
26 | Correct | 34 ms | 47352 KB | Output is correct |
27 | Correct | 50 ms | 48888 KB | Output is correct |
28 | Correct | 47 ms | 48632 KB | Output is correct |
29 | Correct | 50 ms | 48760 KB | Output is correct |
30 | Correct | 49 ms | 48504 KB | Output is correct |
31 | Correct | 51 ms | 48760 KB | Output is correct |
32 | Correct | 49 ms | 48632 KB | Output is correct |
33 | Correct | 51 ms | 48760 KB | Output is correct |
34 | Correct | 49 ms | 48504 KB | Output is correct |
35 | Correct | 56 ms | 48888 KB | Output is correct |
36 | Correct | 57 ms | 49144 KB | Output is correct |
37 | Correct | 60 ms | 49144 KB | Output is correct |
38 | Correct | 56 ms | 49148 KB | Output is correct |
39 | Correct | 61 ms | 49280 KB | Output is correct |
40 | Correct | 56 ms | 49400 KB | Output is correct |
41 | Correct | 56 ms | 49400 KB | Output is correct |
42 | Correct | 57 ms | 49400 KB | Output is correct |
43 | Correct | 58 ms | 49400 KB | Output is correct |
44 | Correct | 59 ms | 49400 KB | Output is correct |
45 | Correct | 57 ms | 49400 KB | Output is correct |
46 | Correct | 57 ms | 49272 KB | Output is correct |
47 | Correct | 56 ms | 49400 KB | Output is correct |
48 | Correct | 326 ms | 68984 KB | Output is correct |
49 | Correct | 335 ms | 69112 KB | Output is correct |
50 | Correct | 340 ms | 69112 KB | Output is correct |
51 | Correct | 315 ms | 68600 KB | Output is correct |
52 | Correct | 288 ms | 66040 KB | Output is correct |
53 | Correct | 315 ms | 67448 KB | Output is correct |
54 | Correct | 305 ms | 65528 KB | Output is correct |
55 | Correct | 318 ms | 65144 KB | Output is correct |
56 | Correct | 305 ms | 64504 KB | Output is correct |
57 | Correct | 1523 ms | 139492 KB | Output is correct |
58 | Correct | 1405 ms | 106812 KB | Output is correct |
59 | Correct | 1397 ms | 106840 KB | Output is correct |
60 | Correct | 1479 ms | 115128 KB | Output is correct |
61 | Correct | 1502 ms | 115192 KB | Output is correct |
62 | Correct | 746 ms | 88312 KB | Output is correct |
63 | Correct | 1047 ms | 97336 KB | Output is correct |
64 | Correct | 898 ms | 91828 KB | Output is correct |
65 | Correct | 532 ms | 77304 KB | Output is correct |