Submission #3294994


Source Code Expand

Copy
import numpy as np
import collections

n=int(input())
v=list(map(int,input().split()))

e=np.array([v[i] for i in range(0,n,2)])
o=np.array([v[i] for i in range(1,n,2)])

se=set(e)
so=set(o)


lle=collections.Counter(e)
llo=collections.Counter(o)
le=[]
for k,v in lle.items():
    le.append([n//2-v,k])
lo=[]
for k,v in llo.items():
    lo.append([n//2-v,k])
le.sort()
lo.sort()

if(len(lle)==1 and len(llo)==1):
    if(e[0]==o[0]):print(n//2)
    else:print(0)
    exit()




if(len(se)==1):
    if(lo[0][1]!=le[0][1]):print(lo[0][0])
    else:print(lo[1][0])
elif(len(so)==1):
    if(lo[0][1]!=le[0][1]):print(le[0][0])
    else:print(le[1][0])
else:
    if(lo[0][1]!=le[0][1]):print(le[0][0]+lo[0][0])
    else:print(min(le[1][0]+lo[0][0],le[0][0]+lo[1][0]))

Submission Info

Submission Time
Task C - /\/\/\/
User shomu36
Language Python3 (3.4.3)
Score 300
Code Size 801 Byte
Status
Exec Time 1120 ms
Memory 42812 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1_3132.txt, sample2_iw.txt, sample3_1111.txt
All 300 / 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 1120 ms 36736 KB
ababa_1.txt 270 ms 27900 KB
eq_0.txt 220 ms 22940 KB
eq_1.txt 221 ms 23068 KB
rnd_17.txt 218 ms 22832 KB
sample1_3132.txt 149 ms 12428 KB
sample2_iw.txt 149 ms 12512 KB
sample3_1111.txt 150 ms 12512 KB
top2_0.txt 228 ms 22940 KB
top2_1.txt 231 ms 22944 KB
top2_2.txt 229 ms 23024 KB
top2_3.txt 231 ms 22952 KB
top2modoki_0.txt 230 ms 22996 KB
top2modoki_1.txt 229 ms 23008 KB
top2modoki_2.txt 227 ms 22988 KB
top2modoki_3.txt 229 ms 22940 KB
vary_1.txt 363 ms 42812 KB
vary_2.txt 351 ms 42444 KB
vary_3.txt 338 ms 33156 KB
zoro_0.txt 149 ms 12512 KB