Submission #590324

# Submission time Handle Problem Language Result Execution time Memory
590324 2022-07-05T20:34:03 Z dnialh Rope (JOI17_rope) PyPy 3
80 / 100
1179 ms 262144 KB
from collections import Counter

import sys as sus
input = sus.stdin.readline

n, m = map(int, input().split())
c = list(map(int, input().split()))

ct = Counter(c)
o = ct.most_common()
odd = Counter()
eve = Counter()

for i in range(n - 1):
    if i % 2:
        odd[(c[i], c[i + 1])] += 1
    else:
        eve[(c[i], c[i + 1])] += 1

out = []
for i in range(1, m + 1):
    res = 0
    for v, vc in o:
        if v == i:
            continue

        bl = odd[(i, v)] + odd[(v, i)]
        br = eve[(i, v)] + eve[(v, i)]

        bad = min(bl, br)

        res = max(res, vc - bad)

        if bad == 0:
            break
    out.append(n - res - ct[i])
print('\n'.join(map(str, out)))
# Verdict Execution time Memory Grader output
1 Correct 39 ms 18608 KB Output is correct
2 Correct 39 ms 18584 KB Output is correct
3 Correct 44 ms 18644 KB Output is correct
4 Correct 38 ms 18548 KB Output is correct
5 Correct 39 ms 18592 KB Output is correct
6 Correct 45 ms 18580 KB Output is correct
7 Correct 42 ms 18648 KB Output is correct
8 Correct 47 ms 18624 KB Output is correct
9 Correct 44 ms 18536 KB Output is correct
10 Correct 41 ms 18648 KB Output is correct
11 Correct 41 ms 18680 KB Output is correct
12 Correct 39 ms 18608 KB Output is correct
13 Correct 43 ms 18656 KB Output is correct
14 Correct 43 ms 18652 KB Output is correct
15 Correct 42 ms 18636 KB Output is correct
16 Correct 40 ms 18636 KB Output is correct
17 Correct 39 ms 18600 KB Output is correct
18 Correct 43 ms 18556 KB Output is correct
19 Correct 40 ms 18576 KB Output is correct
20 Correct 42 ms 18548 KB Output is correct
21 Correct 40 ms 18612 KB Output is correct
22 Correct 41 ms 18568 KB Output is correct
23 Correct 41 ms 18648 KB Output is correct
24 Correct 39 ms 18568 KB Output is correct
25 Correct 42 ms 18608 KB Output is correct
26 Correct 41 ms 18552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 18608 KB Output is correct
2 Correct 39 ms 18584 KB Output is correct
3 Correct 44 ms 18644 KB Output is correct
4 Correct 38 ms 18548 KB Output is correct
5 Correct 39 ms 18592 KB Output is correct
6 Correct 45 ms 18580 KB Output is correct
7 Correct 42 ms 18648 KB Output is correct
8 Correct 47 ms 18624 KB Output is correct
9 Correct 44 ms 18536 KB Output is correct
10 Correct 41 ms 18648 KB Output is correct
11 Correct 41 ms 18680 KB Output is correct
12 Correct 39 ms 18608 KB Output is correct
13 Correct 43 ms 18656 KB Output is correct
14 Correct 43 ms 18652 KB Output is correct
15 Correct 42 ms 18636 KB Output is correct
16 Correct 40 ms 18636 KB Output is correct
17 Correct 39 ms 18600 KB Output is correct
18 Correct 43 ms 18556 KB Output is correct
19 Correct 40 ms 18576 KB Output is correct
20 Correct 42 ms 18548 KB Output is correct
21 Correct 40 ms 18612 KB Output is correct
22 Correct 41 ms 18568 KB Output is correct
23 Correct 41 ms 18648 KB Output is correct
24 Correct 39 ms 18568 KB Output is correct
25 Correct 42 ms 18608 KB Output is correct
26 Correct 41 ms 18552 KB Output is correct
27 Correct 80 ms 30536 KB Output is correct
28 Correct 80 ms 30408 KB Output is correct
29 Correct 83 ms 30564 KB Output is correct
30 Correct 81 ms 30500 KB Output is correct
31 Correct 80 ms 30552 KB Output is correct
32 Correct 81 ms 30524 KB Output is correct
33 Correct 88 ms 30476 KB Output is correct
34 Correct 81 ms 30436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 18608 KB Output is correct
2 Correct 39 ms 18584 KB Output is correct
3 Correct 44 ms 18644 KB Output is correct
4 Correct 38 ms 18548 KB Output is correct
5 Correct 39 ms 18592 KB Output is correct
6 Correct 45 ms 18580 KB Output is correct
7 Correct 42 ms 18648 KB Output is correct
8 Correct 47 ms 18624 KB Output is correct
9 Correct 44 ms 18536 KB Output is correct
10 Correct 41 ms 18648 KB Output is correct
11 Correct 41 ms 18680 KB Output is correct
12 Correct 39 ms 18608 KB Output is correct
13 Correct 43 ms 18656 KB Output is correct
14 Correct 43 ms 18652 KB Output is correct
15 Correct 42 ms 18636 KB Output is correct
16 Correct 40 ms 18636 KB Output is correct
17 Correct 39 ms 18600 KB Output is correct
18 Correct 43 ms 18556 KB Output is correct
19 Correct 40 ms 18576 KB Output is correct
20 Correct 42 ms 18548 KB Output is correct
21 Correct 40 ms 18612 KB Output is correct
22 Correct 41 ms 18568 KB Output is correct
23 Correct 41 ms 18648 KB Output is correct
24 Correct 39 ms 18568 KB Output is correct
25 Correct 42 ms 18608 KB Output is correct
26 Correct 41 ms 18552 KB Output is correct
27 Correct 80 ms 30536 KB Output is correct
28 Correct 80 ms 30408 KB Output is correct
29 Correct 83 ms 30564 KB Output is correct
30 Correct 81 ms 30500 KB Output is correct
31 Correct 80 ms 30552 KB Output is correct
32 Correct 81 ms 30524 KB Output is correct
33 Correct 88 ms 30476 KB Output is correct
34 Correct 81 ms 30436 KB Output is correct
35 Correct 112 ms 38644 KB Output is correct
36 Correct 116 ms 38596 KB Output is correct
37 Correct 114 ms 36228 KB Output is correct
38 Correct 119 ms 39128 KB Output is correct
39 Correct 119 ms 40380 KB Output is correct
40 Correct 123 ms 36988 KB Output is correct
41 Correct 116 ms 36976 KB Output is correct
42 Correct 115 ms 36584 KB Output is correct
43 Correct 111 ms 36328 KB Output is correct
44 Correct 127 ms 35060 KB Output is correct
45 Correct 125 ms 36476 KB Output is correct
46 Correct 134 ms 36116 KB Output is correct
47 Correct 113 ms 34724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 18608 KB Output is correct
2 Correct 39 ms 18584 KB Output is correct
3 Correct 44 ms 18644 KB Output is correct
4 Correct 38 ms 18548 KB Output is correct
5 Correct 39 ms 18592 KB Output is correct
6 Correct 45 ms 18580 KB Output is correct
7 Correct 42 ms 18648 KB Output is correct
8 Correct 47 ms 18624 KB Output is correct
9 Correct 44 ms 18536 KB Output is correct
10 Correct 41 ms 18648 KB Output is correct
11 Correct 41 ms 18680 KB Output is correct
12 Correct 39 ms 18608 KB Output is correct
13 Correct 43 ms 18656 KB Output is correct
14 Correct 43 ms 18652 KB Output is correct
15 Correct 42 ms 18636 KB Output is correct
16 Correct 40 ms 18636 KB Output is correct
17 Correct 39 ms 18600 KB Output is correct
18 Correct 43 ms 18556 KB Output is correct
19 Correct 40 ms 18576 KB Output is correct
20 Correct 42 ms 18548 KB Output is correct
21 Correct 40 ms 18612 KB Output is correct
22 Correct 41 ms 18568 KB Output is correct
23 Correct 41 ms 18648 KB Output is correct
24 Correct 39 ms 18568 KB Output is correct
25 Correct 42 ms 18608 KB Output is correct
26 Correct 41 ms 18552 KB Output is correct
27 Correct 80 ms 30536 KB Output is correct
28 Correct 80 ms 30408 KB Output is correct
29 Correct 83 ms 30564 KB Output is correct
30 Correct 81 ms 30500 KB Output is correct
31 Correct 80 ms 30552 KB Output is correct
32 Correct 81 ms 30524 KB Output is correct
33 Correct 88 ms 30476 KB Output is correct
34 Correct 81 ms 30436 KB Output is correct
35 Correct 112 ms 38644 KB Output is correct
36 Correct 116 ms 38596 KB Output is correct
37 Correct 114 ms 36228 KB Output is correct
38 Correct 119 ms 39128 KB Output is correct
39 Correct 119 ms 40380 KB Output is correct
40 Correct 123 ms 36988 KB Output is correct
41 Correct 116 ms 36976 KB Output is correct
42 Correct 115 ms 36584 KB Output is correct
43 Correct 111 ms 36328 KB Output is correct
44 Correct 127 ms 35060 KB Output is correct
45 Correct 125 ms 36476 KB Output is correct
46 Correct 134 ms 36116 KB Output is correct
47 Correct 113 ms 34724 KB Output is correct
48 Correct 730 ms 197044 KB Output is correct
49 Correct 738 ms 216356 KB Output is correct
50 Correct 721 ms 223896 KB Output is correct
51 Correct 797 ms 169736 KB Output is correct
52 Correct 845 ms 194404 KB Output is correct
53 Correct 834 ms 180264 KB Output is correct
54 Correct 889 ms 147308 KB Output is correct
55 Correct 882 ms 147296 KB Output is correct
56 Correct 914 ms 147452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 18608 KB Output is correct
2 Correct 39 ms 18584 KB Output is correct
3 Correct 44 ms 18644 KB Output is correct
4 Correct 38 ms 18548 KB Output is correct
5 Correct 39 ms 18592 KB Output is correct
6 Correct 45 ms 18580 KB Output is correct
7 Correct 42 ms 18648 KB Output is correct
8 Correct 47 ms 18624 KB Output is correct
9 Correct 44 ms 18536 KB Output is correct
10 Correct 41 ms 18648 KB Output is correct
11 Correct 41 ms 18680 KB Output is correct
12 Correct 39 ms 18608 KB Output is correct
13 Correct 43 ms 18656 KB Output is correct
14 Correct 43 ms 18652 KB Output is correct
15 Correct 42 ms 18636 KB Output is correct
16 Correct 40 ms 18636 KB Output is correct
17 Correct 39 ms 18600 KB Output is correct
18 Correct 43 ms 18556 KB Output is correct
19 Correct 40 ms 18576 KB Output is correct
20 Correct 42 ms 18548 KB Output is correct
21 Correct 40 ms 18612 KB Output is correct
22 Correct 41 ms 18568 KB Output is correct
23 Correct 41 ms 18648 KB Output is correct
24 Correct 39 ms 18568 KB Output is correct
25 Correct 42 ms 18608 KB Output is correct
26 Correct 41 ms 18552 KB Output is correct
27 Correct 80 ms 30536 KB Output is correct
28 Correct 80 ms 30408 KB Output is correct
29 Correct 83 ms 30564 KB Output is correct
30 Correct 81 ms 30500 KB Output is correct
31 Correct 80 ms 30552 KB Output is correct
32 Correct 81 ms 30524 KB Output is correct
33 Correct 88 ms 30476 KB Output is correct
34 Correct 81 ms 30436 KB Output is correct
35 Correct 112 ms 38644 KB Output is correct
36 Correct 116 ms 38596 KB Output is correct
37 Correct 114 ms 36228 KB Output is correct
38 Correct 119 ms 39128 KB Output is correct
39 Correct 119 ms 40380 KB Output is correct
40 Correct 123 ms 36988 KB Output is correct
41 Correct 116 ms 36976 KB Output is correct
42 Correct 115 ms 36584 KB Output is correct
43 Correct 111 ms 36328 KB Output is correct
44 Correct 127 ms 35060 KB Output is correct
45 Correct 125 ms 36476 KB Output is correct
46 Correct 134 ms 36116 KB Output is correct
47 Correct 113 ms 34724 KB Output is correct
48 Correct 730 ms 197044 KB Output is correct
49 Correct 738 ms 216356 KB Output is correct
50 Correct 721 ms 223896 KB Output is correct
51 Correct 797 ms 169736 KB Output is correct
52 Correct 845 ms 194404 KB Output is correct
53 Correct 834 ms 180264 KB Output is correct
54 Correct 889 ms 147308 KB Output is correct
55 Correct 882 ms 147296 KB Output is correct
56 Correct 914 ms 147452 KB Output is correct
57 Runtime error 1179 ms 262144 KB Execution killed with signal 9
58 Halted 0 ms 0 KB -