Submission #3299748

Source Code Expand

Copy
```from collections import defaultdict
import sys
n = int(input())
v = list(map(int, input().split()))

dd_even = defaultdict(int)
dd_odd  = defaultdict(int)

# 偶数番目のヒストグラムを作る
for i in range(0, n, 2):
dd_even[v[i]] += 1

l_even = list(dd_even.items())
l_even.sort(key= lambda x:x[1])
top_even = l_even[-1][0]
#print(l_even)

# 奇数番目のヒストグラムを作る
for i in range(1, n, 2):
dd_odd[v[i]] += 1

l_odd = list(dd_odd.items())
l_odd.sort(key= lambda x:x[1])
#print(l_odd)
top_odd = l_odd[-1][0]

if top_even == top_odd:
if len(l_odd) == 1: # つまり全部同じ数字のとき
res = int(n / 2)
print(res)
sys.exit()
else:
l_odd = [l for l in l_odd if l[0] != l_odd[-2][0]]
else:
l_odd = [l for l in l_odd if l[0] != top_odd]

sum_odd = sum(l[1] for l in l_odd)
#print(l_odd, sum_odd)

l_even = [l for l in l_even if l[0] != top_even]
sum_even = sum(l[1] for l in l_even)
#print(l_even, sum_even)

res = sum_odd + sum_even
print(res)```

#### Submission Info

Submission Time 2018-09-29 22:17:11+0900 C - /\/\/\/ showyou41 Python3 (3.4.3) 0 1071 Byte WA 135 ms 21184 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1_3132.txt, sample2_iw.txt, sample3_1111.txt
All 0 / 300 ababa_0.txt, ababa_1.txt, eq_0.txt, eq_1.txt, rnd_17.txt, sample1_3132.txt, sample2_iw.txt, sample3_1111.txt, top2_0.txt, top2_1.txt, top2_2.txt, top2_3.txt, top2modoki_0.txt, top2modoki_1.txt, top2modoki_2.txt, top2modoki_3.txt, vary_1.txt, vary_2.txt, vary_3.txt, zoro_0.txt
Case Name Status Exec Time Memory
ababa_0.txt 94 ms 15208 KB
ababa_1.txt 101 ms 14300 KB
eq_0.txt 65 ms 14232 KB
eq_1.txt 65 ms 14360 KB
rnd_17.txt 64 ms 14264 KB
sample1_3132.txt 21 ms 3316 KB
sample2_iw.txt 21 ms 3316 KB
sample3_1111.txt 21 ms 3316 KB
top2_0.txt 68 ms 14232 KB
top2_1.txt 70 ms 14140 KB
top2_2.txt 69 ms 14140 KB
top2_3.txt 70 ms 14240 KB
top2modoki_0.txt 70 ms 14892 KB
top2modoki_1.txt 69 ms 14308 KB
top2modoki_2.txt 68 ms 14364 KB
top2modoki_3.txt 70 ms 13852 KB
vary_1.txt 135 ms 21184 KB
vary_2.txt 131 ms 20912 KB
vary_3.txt 109 ms 15492 KB
zoro_0.txt 21 ms 3316 KB