結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー 👑 H20H20
提出日時 2021-11-12 22:28:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 278 ms / 3,000 ms
コード長 691 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,008 KB
実行使用メモリ 107,876 KB
最終ジャッジ日時 2024-05-04 09:36:27
合計ジャッジ時間 7,814 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,916 KB
testcase_01 AC 37 ms
52,644 KB
testcase_02 AC 37 ms
52,908 KB
testcase_03 AC 42 ms
61,700 KB
testcase_04 AC 235 ms
93,860 KB
testcase_05 AC 278 ms
92,304 KB
testcase_06 AC 200 ms
106,272 KB
testcase_07 AC 46 ms
61,268 KB
testcase_08 AC 120 ms
84,080 KB
testcase_09 AC 146 ms
88,816 KB
testcase_10 AC 161 ms
89,068 KB
testcase_11 AC 137 ms
86,084 KB
testcase_12 AC 56 ms
73,596 KB
testcase_13 AC 174 ms
91,132 KB
testcase_14 AC 200 ms
88,120 KB
testcase_15 AC 208 ms
90,892 KB
testcase_16 AC 167 ms
85,088 KB
testcase_17 AC 153 ms
86,804 KB
testcase_18 AC 182 ms
86,776 KB
testcase_19 AC 129 ms
86,152 KB
testcase_20 AC 104 ms
81,760 KB
testcase_21 AC 165 ms
95,300 KB
testcase_22 AC 202 ms
89,160 KB
testcase_23 AC 245 ms
107,876 KB
testcase_24 AC 254 ms
92,296 KB
testcase_25 AC 261 ms
91,688 KB
testcase_26 AC 242 ms
98,456 KB
testcase_27 AC 242 ms
106,880 KB
testcase_28 AC 248 ms
97,892 KB
testcase_29 AC 247 ms
103,964 KB
testcase_30 AC 255 ms
95,620 KB
testcase_31 AC 253 ms
93,968 KB
testcase_32 AC 270 ms
91,668 KB
testcase_33 AC 45 ms
59,900 KB
testcase_34 AC 42 ms
59,700 KB
testcase_35 AC 53 ms
63,888 KB
testcase_36 AC 54 ms
63,616 KB
testcase_37 AC 48 ms
62,856 KB
testcase_38 AC 49 ms
61,644 KB
testcase_39 AC 54 ms
64,460 KB
testcase_40 AC 47 ms
60,912 KB
testcase_41 AC 49 ms
62,148 KB
testcase_42 AC 48 ms
60,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def is_ok(K):
    HH = [0]*N
    for i in range(N):
        HH[i]=H[i]-K
    y = Y*B
    j = 0
    while y>0 and j<N:
        d = min(y,HH[j])
        if d>0:
            HH[j]-=d
            y-=d
        j+=1
    return max(HH)<=0

def meguru_bisect(ok, ng):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

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

HQ = []
for i in range(N):
    heapq.heappush(HQ,(-H[i],i))
for _ in range(A):
    hi,i = heapq.heappop(HQ)
    H[i]-=X
    heapq.heappush(HQ,(-H[i],i))


print(meguru_bisect(10**9 + 1,-1))
0