Submission #3291693

Source Code Expand

Copy
N = gets.to_i
vs = gets.split.map(&:to_i)
hashes = Array.new(2){Hash.new(0)}
hashes[0][0] = 0
hashes[1][0] = 0

N.times do |i|
    hashes[i%2][vs[i]] += 1
end

a1 = hashes[0].to_a.sort_by{|a| -a[1]}
a2 = hashes[1].to_a.sort_by{|a| -a[1]}
if a1[0][0] != a2[0][0]
    num = a1[0][1] + a2[0][1]
else
    num = [a1[0][1] + a2[1][1], a1[1][1] + a2[0][1]].max
end
puts N - num

Submission Info

Submission Time
Task C - /\/\/\/
User betrue12
Language Ruby (2.3.3)
Score 300
Code Size 387 Byte
Status
Exec Time 143 ms
Memory 21488 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 97 ms 15240 KB
ababa_1.txt 98 ms 15264 KB
eq_0.txt 59 ms 8076 KB
eq_1.txt 59 ms 8076 KB
rnd_17.txt 59 ms 8076 KB
sample1_3132.txt 7 ms 1788 KB
sample2_iw.txt 7 ms 1788 KB
sample3_1111.txt 7 ms 1788 KB
top2_0.txt 67 ms 8968 KB
top2_1.txt 67 ms 8968 KB
top2_2.txt 66 ms 8968 KB
top2_3.txt 66 ms 8968 KB
top2modoki_0.txt 67 ms 8968 KB
top2modoki_1.txt 67 ms 8968 KB
top2modoki_2.txt 66 ms 8968 KB
top2modoki_3.txt 66 ms 8968 KB
vary_1.txt 143 ms 21488 KB
vary_2.txt 139 ms 21244 KB
vary_3.txt 120 ms 16764 KB
zoro_0.txt 7 ms 1788 KB