結果

問題 No.1071 ベホマラー
ユーザー titiatitia
提出日時 2020-06-05 21:31:07
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 19,152 KB
最終ジャッジ日時 2023-08-22 14:22:46
合計ジャッジ時間 3,677 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,148 KB
testcase_01 AC 16 ms
8,304 KB
testcase_02 AC 15 ms
8,216 KB
testcase_03 AC 15 ms
8,272 KB
testcase_04 AC 16 ms
8,140 KB
testcase_05 AC 15 ms
8,252 KB
testcase_06 AC 16 ms
8,280 KB
testcase_07 AC 15 ms
8,180 KB
testcase_08 AC 15 ms
8,260 KB
testcase_09 AC 15 ms
8,172 KB
testcase_10 AC 176 ms
17,144 KB
testcase_11 AC 182 ms
16,944 KB
testcase_12 AC 118 ms
13,924 KB
testcase_13 AC 103 ms
16,016 KB
testcase_14 AC 193 ms
17,680 KB
testcase_15 AC 212 ms
19,008 KB
testcase_16 AC 212 ms
18,936 KB
testcase_17 AC 140 ms
19,108 KB
testcase_18 AC 119 ms
19,116 KB
testcase_19 AC 171 ms
18,972 KB
testcase_20 AC 107 ms
19,152 KB
testcase_21 AC 114 ms
18,936 KB
testcase_22 AC 106 ms
19,084 KB
testcase_23 AC 113 ms
19,124 KB
testcase_24 AC 193 ms
18,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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