Submission #3211836


Source Code Expand

Copy
N, X, *XS = $stdin.read.split.map(&:to_i)

def getn(xs)
  ret = 0
  ret += xs.last + X; n_garbages = 1
  xs.reverse.each_cons(2) do |x2, x1|
    cost = (n_garbages + 1)**2 * (x2-x1)
    ret += cost
    ret += X
    n_garbages += 1
  end
  ret += (n_garbages + 1)**2 * xs[0]
  ret += X
  ret
end

ids = (0...N).to_a
p (1..N).map{|k|
  (0...k).map{|m|
    getn(XS.values_at(*ids.select{|i| i % k == m}))
  }.inject(0, :+)
}.min

Submission Info

Submission Time
Task B - Garbage Collector
User yhara
Language Ruby (2.3.3)
Score 0
Code Size 448 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 0 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt
All 0 / 300 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt
Case Name Status Exec Time Memory
sample_01.txt 7 ms 1788 KB
sample_02.txt 7 ms 1788 KB
sample_03.txt 7 ms 1788 KB
sample_04.txt 7 ms 1788 KB
stest_01.txt
stest_02.txt
stest_03.txt 14 ms 2172 KB
stest_04.txt 148 ms 3580 KB
stest_05.txt
stest_06.txt
stest_07.txt
stest_08.txt
stest_09.txt
stest_10.txt
stest_11.txt
stest_12.txt 862 ms 5296 KB
test_13.txt
test_14.txt
test_15.txt
test_16.txt
test_17.txt
test_18.txt
test_19.txt
test_20.txt
test_21.txt
test_22.txt
test_23.txt
test_24.txt
test_25.txt
test_26.txt
test_27.txt
test_28.txt