結果

問題 No.1071 ベホマラー
ユーザー neterukunneterukun
提出日時 2020-06-05 21:31:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,780 KB
実行使用メモリ 87,612 KB
最終ジャッジ日時 2024-12-17 13:32:04
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x, y = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] -= 1

# 残りがcnt人以上ならベホマラーがお得
cnt = -((-y) // x)
a = sorted(a)
ind = n - cnt
if ind < 0:
    cnt_y = 0
    ans = 0
else:
    cnt_y = -((-a[ind]) // k)
    ans = cnt_y * y

for i in range(n):
    a[i] -= cnt_y * k
    if a[i] > 0:
        ans += -((-a[i]) // k) * x
print(ans)
0