結果

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

ソースコード

diff #

n, k, x, y = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    if a[i] == 1:
        a[i] = 0
    else:
        a[i] = (a[i] - 2) // k + 1
a.sort()
ans = 0
for i in range(n):
    t = a[i + 1] - a[i]
    if (n - i) * x > y:
        ans += y * t
    else:
        ans += x * t
        a[i + 1] = a[i]
print(ans)
0