結果

問題 No.1071 ベホマラー
ユーザー simansiman
提出日時 2020-08-31 05:23:02
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 390 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 24,540 KB
最終ジャッジ日時 2023-08-09 19:22:48
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,344 KB
testcase_01 AC 81 ms
15,160 KB
testcase_02 AC 82 ms
15,176 KB
testcase_03 AC 81 ms
15,052 KB
testcase_04 AC 81 ms
15,152 KB
testcase_05 AC 81 ms
15,328 KB
testcase_06 AC 81 ms
15,072 KB
testcase_07 AC 81 ms
15,248 KB
testcase_08 AC 83 ms
15,332 KB
testcase_09 AC 81 ms
15,048 KB
testcase_10 AC 136 ms
21,700 KB
testcase_11 WA -
testcase_12 AC 119 ms
19,748 KB
testcase_13 AC 132 ms
21,096 KB
testcase_14 AC 138 ms
22,300 KB
testcase_15 AC 157 ms
23,604 KB
testcase_16 AC 157 ms
23,580 KB
testcase_17 AC 161 ms
24,092 KB
testcase_18 AC 164 ms
24,364 KB
testcase_19 AC 160 ms
23,852 KB
testcase_20 AC 153 ms
24,480 KB
testcase_21 WA -
testcase_22 AC 151 ms
24,508 KB
testcase_23 AC 154 ms
24,540 KB
testcase_24 AC 152 ms
23,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K, X, Y = gets.split.map(&:to_i)
A = gets.split.map { |a| a.to_i - 1 }.sort
C = A.map { |a| a / K + (a % K == 0 ? 0 : 1) }

if X >= Y
  puts C.max
  exit
end

if N * X <= Y
  puts C.map { |c| c * X }.sum
  exit
end

ok = Y / X

bhm_cnt = ok == N ? 0 : C[N - ok - 1]
bh_cnt = C[N - ok..].map { |c| c - bhm_cnt }.sum

# p [:bh_cnt, bh_cnt, :bhm_cnt, bhm_cnt]
puts X * bh_cnt + Y * bhm_cnt
0