結果

問題 No.1071 ベホマラー
ユーザー yuruhiyayuruhiya
提出日時 2020-06-05 21:41:22
言語 Crystal
(1.11.2)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 325 bytes
コンパイル時間 19,127 ms
コンパイル使用メモリ 263,224 KB
実行使用メモリ 43,360 KB
最終ジャッジ日時 2023-09-13 10:41:55
合計ジャッジ時間 24,543 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,832 KB
testcase_01 AC 3 ms
4,864 KB
testcase_02 AC 2 ms
4,920 KB
testcase_03 AC 3 ms
4,832 KB
testcase_04 AC 3 ms
4,928 KB
testcase_05 AC 3 ms
4,964 KB
testcase_06 AC 3 ms
4,972 KB
testcase_07 AC 3 ms
5,004 KB
testcase_08 AC 3 ms
5,056 KB
testcase_09 AC 3 ms
4,860 KB
testcase_10 AC 230 ms
32,116 KB
testcase_11 AC 210 ms
33,600 KB
testcase_12 AC 132 ms
25,212 KB
testcase_13 AC 185 ms
30,968 KB
testcase_14 AC 255 ms
25,604 KB
testcase_15 AC 272 ms
36,576 KB
testcase_16 AC 270 ms
35,808 KB
testcase_17 AC 270 ms
35,428 KB
testcase_18 AC 269 ms
35,448 KB
testcase_19 AC 269 ms
35,404 KB
testcase_20 AC 205 ms
43,360 KB
testcase_21 AC 204 ms
42,636 KB
testcase_22 AC 206 ms
42,492 KB
testcase_23 AC 207 ms
42,132 KB
testcase_24 AC 262 ms
35,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

require "big"
n, k, x, y = read_line.split.map &.to_big_i
a = read_line.split.map &.to_big_i
b = a.map { |i| (i + k - 2)//k }.sort
cul = [0.to_big_i] * (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] + x * (cul[i + 1] - b[i] * (n - 1 - i))
}
0