結果

問題 No.1071 ベホマラー
コンテスト
ユーザー qumazaki
提出日時 2020-06-06 01:49:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 376 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 339 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 84,992 KB
最終ジャッジ日時 2026-05-27 01:11:12
合計ジャッジ時間 3,653 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

# ベホイミのほうが効率が良い最大人数
upper = y//x
if(upper < n):
    bhm = 1 + (a[upper]-1-1)//k
else:
    upper = n
    bhm = 0

ans = y*bhm
for i in a[:upper]:
    remain = i - k*bhm
    if(remain<=0):
        continue
    ans += (1+(remain-1-1)//k) * x

print(ans)
0