結果

問題 No.1071 ベホマラー
ユーザー titia
提出日時 2020-06-05 21:31:07
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 165 ms / 2,000 ms
+ 105µs
コード長 440 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 84 ms
コンパイル使用メモリ 14,592 KB
実行使用メモリ 21,096 KB
最終ジャッジ日時 2026-10-30 01:23:14
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N,K,X,Y=map(int,input().split())
A=list(map(int,input().split()))

R=[(a-1+K-1)//K for a in A]
import heapq
heapq.heapify(R)

ANS=0
common=0

#print(R)

while R:
    #print(ANS,R)
    while R and R[0]<=common:
        heapq.heappop(R)

    if len(R)*X>Y:
        ANS+=(R[0]-common)*Y
        common+=R[0]-common
    else:
        for t in R:
            ANS+=max(0,t-common)*X
        break
print(ANS)
0