結果

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

ソースコード

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