結果

問題 No.1071 ベホマラー
ユーザー shi-moshi-mo
提出日時 2020-10-01 23:26:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 11,360 KB
実行使用メモリ 25,940 KB
最終ジャッジ日時 2023-09-21 12:53:31
合計ジャッジ時間 4,461 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,040 KB
testcase_01 AC 75 ms
15,080 KB
testcase_02 AC 75 ms
14,924 KB
testcase_03 AC 75 ms
15,184 KB
testcase_04 AC 75 ms
15,124 KB
testcase_05 AC 75 ms
14,968 KB
testcase_06 AC 76 ms
15,160 KB
testcase_07 AC 75 ms
15,184 KB
testcase_08 AC 74 ms
15,152 KB
testcase_09 AC 74 ms
15,000 KB
testcase_10 AC 141 ms
21,100 KB
testcase_11 AC 154 ms
21,304 KB
testcase_12 AC 118 ms
20,160 KB
testcase_13 AC 149 ms
20,736 KB
testcase_14 AC 148 ms
21,604 KB
testcase_15 AC 177 ms
25,164 KB
testcase_16 AC 159 ms
24,996 KB
testcase_17 AC 183 ms
25,488 KB
testcase_18 AC 166 ms
25,524 KB
testcase_19 AC 163 ms
25,224 KB
testcase_20 AC 155 ms
25,924 KB
testcase_21 AC 148 ms
24,980 KB
testcase_22 AC 157 ms
25,940 KB
testcase_23 AC 155 ms
25,892 KB
testcase_24 AC 154 ms
25,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, h, x, y = gets.split.map(&:to_i)
a = gets.split.map{|ai| ai.to_i-1 }.sort!
c = a.map{|ai| Rational(ai, h).ceil }

if y <= x
  puts y * c.max
  exit
end
if n*x <= y
  puts c.map{|ci| ci*x }.sum
  exit
end

ny = Rational(y, x).ceil
cy = c[n - ny]
cx = c[(n-ny+1)..].map{|ci| ci - cy }.sum
puts x*cx + y*cy
0