結果

問題 No.1071 ベホマラー
ユーザー s_shohei
提出日時 2020-08-02 17:56:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 93,440 KB
最終ジャッジ日時 2024-07-19 03:43:19
合計ジャッジ時間 3,525 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def ceil(a,b):
    return ((a - 1) // b) + 1

for tmp in a:
    if tmp==1:
        continue
    newa.append(ceil(tmp-1,k))

newa.sort()

all_cnt=0
single_cnt=0
nokori=len(newa)

for num in newa:
    need = num - all_cnt
    if nokori*x >= y:
        all_cnt+=need
        nokori-=1
    else:
        single_cnt+=need

print(all_cnt*y + single_cnt*x)
0