-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.py
More file actions
44 lines (32 loc) · 702 Bytes
/
C.py
File metadata and controls
44 lines (32 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v1_c = Counter(v[::2])
v2_c = Counter(v[1::2])
v1_c = sorted(list(v1_c.items()), key=lambda x: x[1])
v2_c = sorted(list(v2_c.items()), key=lambda x: x[1])
v1 = v1_c
v2 = v2_c
ans_1 = 0
if v1[-1][0]==v2[-1][0]:
ans_1 += v1[-1][1]
v1 = v1[:-1]
if len(v1)>=2:
for i, j in v1[:-1]:
ans_1 += j
if len(v2)>=2:
for i, j in v2[:-1]:
ans_1 += j
v1 = v1_c
v2 = v2_c
ans_2 = 0
if v1[-1][0]==v2[-1][0]:
ans_2 += v2[-1][1]
v2 = v2[:-1]
if len(v2)>=2:
for i, j in v2[:-1]:
ans_2 += j
if len(v1)>=2:
for i, j in v1[:-1]:
ans_2 += j
print(min(ans_1, ans_2))