답안 #590330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590330 2022-07-05T20:40:18 Z dnialh Rope (JOI17_rope) PyPy 3
80 / 100
1738 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):
    s = min(c[i], c[i + 1])
    b = max(c[i], c[i + 1])
    if i % 2:
        odd[(s << 20) |  b] += 1
    else:
        eve[(s << 20) |  b] += 1
 
out = []
for i in range(1, m + 1):
    res = 0
    for v, vc in o:
        if v == i:
            continue
 
        bl = odd[i << 20 | v] + odd[v << 20 | i]
        br = eve[v << 20 | i] + eve[i << 20 | v]
 
        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)))
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 18528 KB Output is correct
2 Correct 38 ms 18616 KB Output is correct
3 Correct 39 ms 18600 KB Output is correct
4 Correct 53 ms 18632 KB Output is correct
5 Correct 42 ms 18620 KB Output is correct
6 Correct 43 ms 18756 KB Output is correct
7 Correct 41 ms 18580 KB Output is correct
8 Correct 46 ms 18576 KB Output is correct
9 Correct 43 ms 18592 KB Output is correct
10 Correct 39 ms 18604 KB Output is correct
11 Correct 39 ms 18548 KB Output is correct
12 Correct 42 ms 18608 KB Output is correct
13 Correct 40 ms 18604 KB Output is correct
14 Correct 41 ms 18644 KB Output is correct
15 Correct 46 ms 18564 KB Output is correct
16 Correct 43 ms 18612 KB Output is correct
17 Correct 40 ms 18644 KB Output is correct
18 Correct 39 ms 18568 KB Output is correct
19 Correct 40 ms 18600 KB Output is correct
20 Correct 42 ms 18568 KB Output is correct
21 Correct 40 ms 18580 KB Output is correct
22 Correct 39 ms 18608 KB Output is correct
23 Correct 45 ms 18600 KB Output is correct
24 Correct 39 ms 18544 KB Output is correct
25 Correct 40 ms 18572 KB Output is correct
26 Correct 44 ms 18540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 18528 KB Output is correct
2 Correct 38 ms 18616 KB Output is correct
3 Correct 39 ms 18600 KB Output is correct
4 Correct 53 ms 18632 KB Output is correct
5 Correct 42 ms 18620 KB Output is correct
6 Correct 43 ms 18756 KB Output is correct
7 Correct 41 ms 18580 KB Output is correct
8 Correct 46 ms 18576 KB Output is correct
9 Correct 43 ms 18592 KB Output is correct
10 Correct 39 ms 18604 KB Output is correct
11 Correct 39 ms 18548 KB Output is correct
12 Correct 42 ms 18608 KB Output is correct
13 Correct 40 ms 18604 KB Output is correct
14 Correct 41 ms 18644 KB Output is correct
15 Correct 46 ms 18564 KB Output is correct
16 Correct 43 ms 18612 KB Output is correct
17 Correct 40 ms 18644 KB Output is correct
18 Correct 39 ms 18568 KB Output is correct
19 Correct 40 ms 18600 KB Output is correct
20 Correct 42 ms 18568 KB Output is correct
21 Correct 40 ms 18580 KB Output is correct
22 Correct 39 ms 18608 KB Output is correct
23 Correct 45 ms 18600 KB Output is correct
24 Correct 39 ms 18544 KB Output is correct
25 Correct 40 ms 18572 KB Output is correct
26 Correct 44 ms 18540 KB Output is correct
27 Correct 86 ms 30476 KB Output is correct
28 Correct 86 ms 30396 KB Output is correct
29 Correct 89 ms 30400 KB Output is correct
30 Correct 86 ms 30496 KB Output is correct
31 Correct 86 ms 30412 KB Output is correct
32 Correct 84 ms 30368 KB Output is correct
33 Correct 85 ms 30344 KB Output is correct
34 Correct 92 ms 30380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 18528 KB Output is correct
2 Correct 38 ms 18616 KB Output is correct
3 Correct 39 ms 18600 KB Output is correct
4 Correct 53 ms 18632 KB Output is correct
5 Correct 42 ms 18620 KB Output is correct
6 Correct 43 ms 18756 KB Output is correct
7 Correct 41 ms 18580 KB Output is correct
8 Correct 46 ms 18576 KB Output is correct
9 Correct 43 ms 18592 KB Output is correct
10 Correct 39 ms 18604 KB Output is correct
11 Correct 39 ms 18548 KB Output is correct
12 Correct 42 ms 18608 KB Output is correct
13 Correct 40 ms 18604 KB Output is correct
14 Correct 41 ms 18644 KB Output is correct
15 Correct 46 ms 18564 KB Output is correct
16 Correct 43 ms 18612 KB Output is correct
17 Correct 40 ms 18644 KB Output is correct
18 Correct 39 ms 18568 KB Output is correct
19 Correct 40 ms 18600 KB Output is correct
20 Correct 42 ms 18568 KB Output is correct
21 Correct 40 ms 18580 KB Output is correct
22 Correct 39 ms 18608 KB Output is correct
23 Correct 45 ms 18600 KB Output is correct
24 Correct 39 ms 18544 KB Output is correct
25 Correct 40 ms 18572 KB Output is correct
26 Correct 44 ms 18540 KB Output is correct
27 Correct 86 ms 30476 KB Output is correct
28 Correct 86 ms 30396 KB Output is correct
29 Correct 89 ms 30400 KB Output is correct
30 Correct 86 ms 30496 KB Output is correct
31 Correct 86 ms 30412 KB Output is correct
32 Correct 84 ms 30368 KB Output is correct
33 Correct 85 ms 30344 KB Output is correct
34 Correct 92 ms 30380 KB Output is correct
35 Correct 130 ms 35452 KB Output is correct
36 Correct 128 ms 35332 KB Output is correct
37 Correct 111 ms 35156 KB Output is correct
38 Correct 113 ms 35420 KB Output is correct
39 Correct 124 ms 35252 KB Output is correct
40 Correct 128 ms 34804 KB Output is correct
41 Correct 124 ms 35208 KB Output is correct
42 Correct 125 ms 31632 KB Output is correct
43 Correct 130 ms 33356 KB Output is correct
44 Correct 142 ms 35864 KB Output is correct
45 Correct 158 ms 35148 KB Output is correct
46 Correct 130 ms 31776 KB Output is correct
47 Correct 135 ms 32332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 18528 KB Output is correct
2 Correct 38 ms 18616 KB Output is correct
3 Correct 39 ms 18600 KB Output is correct
4 Correct 53 ms 18632 KB Output is correct
5 Correct 42 ms 18620 KB Output is correct
6 Correct 43 ms 18756 KB Output is correct
7 Correct 41 ms 18580 KB Output is correct
8 Correct 46 ms 18576 KB Output is correct
9 Correct 43 ms 18592 KB Output is correct
10 Correct 39 ms 18604 KB Output is correct
11 Correct 39 ms 18548 KB Output is correct
12 Correct 42 ms 18608 KB Output is correct
13 Correct 40 ms 18604 KB Output is correct
14 Correct 41 ms 18644 KB Output is correct
15 Correct 46 ms 18564 KB Output is correct
16 Correct 43 ms 18612 KB Output is correct
17 Correct 40 ms 18644 KB Output is correct
18 Correct 39 ms 18568 KB Output is correct
19 Correct 40 ms 18600 KB Output is correct
20 Correct 42 ms 18568 KB Output is correct
21 Correct 40 ms 18580 KB Output is correct
22 Correct 39 ms 18608 KB Output is correct
23 Correct 45 ms 18600 KB Output is correct
24 Correct 39 ms 18544 KB Output is correct
25 Correct 40 ms 18572 KB Output is correct
26 Correct 44 ms 18540 KB Output is correct
27 Correct 86 ms 30476 KB Output is correct
28 Correct 86 ms 30396 KB Output is correct
29 Correct 89 ms 30400 KB Output is correct
30 Correct 86 ms 30496 KB Output is correct
31 Correct 86 ms 30412 KB Output is correct
32 Correct 84 ms 30368 KB Output is correct
33 Correct 85 ms 30344 KB Output is correct
34 Correct 92 ms 30380 KB Output is correct
35 Correct 130 ms 35452 KB Output is correct
36 Correct 128 ms 35332 KB Output is correct
37 Correct 111 ms 35156 KB Output is correct
38 Correct 113 ms 35420 KB Output is correct
39 Correct 124 ms 35252 KB Output is correct
40 Correct 128 ms 34804 KB Output is correct
41 Correct 124 ms 35208 KB Output is correct
42 Correct 125 ms 31632 KB Output is correct
43 Correct 130 ms 33356 KB Output is correct
44 Correct 142 ms 35864 KB Output is correct
45 Correct 158 ms 35148 KB Output is correct
46 Correct 130 ms 31776 KB Output is correct
47 Correct 135 ms 32332 KB Output is correct
48 Correct 645 ms 155764 KB Output is correct
49 Correct 666 ms 157176 KB Output is correct
50 Correct 669 ms 148948 KB Output is correct
51 Correct 723 ms 139148 KB Output is correct
52 Correct 724 ms 131824 KB Output is correct
53 Correct 712 ms 132740 KB Output is correct
54 Correct 769 ms 128912 KB Output is correct
55 Correct 726 ms 129356 KB Output is correct
56 Correct 623 ms 129892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 18528 KB Output is correct
2 Correct 38 ms 18616 KB Output is correct
3 Correct 39 ms 18600 KB Output is correct
4 Correct 53 ms 18632 KB Output is correct
5 Correct 42 ms 18620 KB Output is correct
6 Correct 43 ms 18756 KB Output is correct
7 Correct 41 ms 18580 KB Output is correct
8 Correct 46 ms 18576 KB Output is correct
9 Correct 43 ms 18592 KB Output is correct
10 Correct 39 ms 18604 KB Output is correct
11 Correct 39 ms 18548 KB Output is correct
12 Correct 42 ms 18608 KB Output is correct
13 Correct 40 ms 18604 KB Output is correct
14 Correct 41 ms 18644 KB Output is correct
15 Correct 46 ms 18564 KB Output is correct
16 Correct 43 ms 18612 KB Output is correct
17 Correct 40 ms 18644 KB Output is correct
18 Correct 39 ms 18568 KB Output is correct
19 Correct 40 ms 18600 KB Output is correct
20 Correct 42 ms 18568 KB Output is correct
21 Correct 40 ms 18580 KB Output is correct
22 Correct 39 ms 18608 KB Output is correct
23 Correct 45 ms 18600 KB Output is correct
24 Correct 39 ms 18544 KB Output is correct
25 Correct 40 ms 18572 KB Output is correct
26 Correct 44 ms 18540 KB Output is correct
27 Correct 86 ms 30476 KB Output is correct
28 Correct 86 ms 30396 KB Output is correct
29 Correct 89 ms 30400 KB Output is correct
30 Correct 86 ms 30496 KB Output is correct
31 Correct 86 ms 30412 KB Output is correct
32 Correct 84 ms 30368 KB Output is correct
33 Correct 85 ms 30344 KB Output is correct
34 Correct 92 ms 30380 KB Output is correct
35 Correct 130 ms 35452 KB Output is correct
36 Correct 128 ms 35332 KB Output is correct
37 Correct 111 ms 35156 KB Output is correct
38 Correct 113 ms 35420 KB Output is correct
39 Correct 124 ms 35252 KB Output is correct
40 Correct 128 ms 34804 KB Output is correct
41 Correct 124 ms 35208 KB Output is correct
42 Correct 125 ms 31632 KB Output is correct
43 Correct 130 ms 33356 KB Output is correct
44 Correct 142 ms 35864 KB Output is correct
45 Correct 158 ms 35148 KB Output is correct
46 Correct 130 ms 31776 KB Output is correct
47 Correct 135 ms 32332 KB Output is correct
48 Correct 645 ms 155764 KB Output is correct
49 Correct 666 ms 157176 KB Output is correct
50 Correct 669 ms 148948 KB Output is correct
51 Correct 723 ms 139148 KB Output is correct
52 Correct 724 ms 131824 KB Output is correct
53 Correct 712 ms 132740 KB Output is correct
54 Correct 769 ms 128912 KB Output is correct
55 Correct 726 ms 129356 KB Output is correct
56 Correct 623 ms 129892 KB Output is correct
57 Runtime error 1738 ms 262144 KB Execution killed with signal 9
58 Halted 0 ms 0 KB -