結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー AEnAEn
提出日時 2022-12-06 21:16:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,705 ms / 3,000 ms
コード長 620 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 134,400 KB
最終ジャッジ日時 2024-04-21 10:25:23
合計ジャッジ時間 30,984 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,224 KB
testcase_01 AC 38 ms
52,736 KB
testcase_02 AC 39 ms
52,736 KB
testcase_03 AC 39 ms
52,480 KB
testcase_04 AC 1,207 ms
114,176 KB
testcase_05 AC 1,568 ms
124,908 KB
testcase_06 AC 509 ms
120,316 KB
testcase_07 AC 39 ms
52,224 KB
testcase_08 AC 229 ms
96,676 KB
testcase_09 AC 271 ms
101,644 KB
testcase_10 AC 824 ms
86,400 KB
testcase_11 AC 510 ms
88,320 KB
testcase_12 AC 69 ms
71,680 KB
testcase_13 AC 866 ms
110,724 KB
testcase_14 AC 1,047 ms
107,092 KB
testcase_15 AC 827 ms
115,700 KB
testcase_16 AC 1,032 ms
86,016 KB
testcase_17 AC 524 ms
95,872 KB
testcase_18 AC 1,047 ms
89,192 KB
testcase_19 AC 202 ms
82,176 KB
testcase_20 AC 202 ms
82,048 KB
testcase_21 AC 438 ms
94,344 KB
testcase_22 AC 861 ms
114,092 KB
testcase_23 AC 1,380 ms
132,864 KB
testcase_24 AC 1,500 ms
124,152 KB
testcase_25 AC 1,628 ms
112,204 KB
testcase_26 AC 1,390 ms
134,400 KB
testcase_27 AC 1,705 ms
118,528 KB
testcase_28 AC 1,423 ms
134,120 KB
testcase_29 AC 1,643 ms
118,656 KB
testcase_30 AC 1,466 ms
127,184 KB
testcase_31 AC 1,446 ms
134,388 KB
testcase_32 AC 1,606 ms
121,608 KB
testcase_33 AC 75 ms
71,680 KB
testcase_34 AC 39 ms
52,736 KB
testcase_35 AC 86 ms
76,288 KB
testcase_36 AC 84 ms
75,616 KB
testcase_37 AC 49 ms
61,184 KB
testcase_38 AC 83 ms
76,288 KB
testcase_39 AC 70 ms
72,960 KB
testcase_40 AC 63 ms
66,560 KB
testcase_41 AC 85 ms
75,904 KB
testcase_42 AC 83 ms
72,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush

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

def judge(k):
    q = []
    sm = 0
    for i in range(N):
        if H[i]>k:
            heappush(q,-H[i]+k)
            sm += H[i]-k
    cnt = A
    while q and cnt>0:
        v = -heappop(q)
        if v>X:
            sm -= X
            heappush(q,-v+X)
        else:
            sm -= v
        cnt -= 1
    if sm<=B*Y:
        return True
    else:
        return False

ok, ng = 10**9,-1
while ok-ng>1:
    mid = (ok+ng)//2
    if judge(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0