結果

問題 No.1071 ベホマラー
ユーザー yuruhiyayuruhiya
提出日時 2020-06-05 21:33:56
言語 Crystal
(1.11.2)
結果
RE  
実行時間 -
コード長 290 bytes
コンパイル時間 22,118 ms
コンパイル使用メモリ 260,340 KB
実行使用メモリ 15,572 KB
最終ジャッジ日時 2023-09-13 10:42:49
合計ジャッジ時間 20,299 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,420 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,480 KB
testcase_04 AC 3 ms
4,392 KB
testcase_05 AC 2 ms
4,548 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,536 KB
testcase_08 AC 3 ms
4,536 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 25 ms
9,656 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 37 ms
15,376 KB
testcase_18 AC 36 ms
15,248 KB
testcase_19 AC 37 ms
15,320 KB
testcase_20 AC 25 ms
14,248 KB
testcase_21 AC 25 ms
14,352 KB
testcase_22 AC 25 ms
14,272 KB
testcase_23 AC 25 ms
14,316 KB
testcase_24 AC 29 ms
15,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x, y = read_line.split.map &.to_i64
a = read_line.split.map &.to_i64
b = a.map { |i| (i + k - 2)//k }.sort
cul = [0_i64]*(n + 1)
n.pred.downto(0) do |i|
  cul[i] = cul[i + 1] + b[i]
end

y = x*n if y > x*n
puts n.times.to_a.min_of { |i|
  y*b[i] + (cul[i + 1] - b[i]*(n - 1 - i))*x
}
0