結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー 👑 H20H20
提出日時 2021-11-12 22:28:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 327 ms / 3,000 ms
コード長 691 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 109,356 KB
最終ジャッジ日時 2023-08-17 02:24:47
合計ジャッジ時間 10,285 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,348 KB
testcase_01 AC 71 ms
71,660 KB
testcase_02 AC 73 ms
71,460 KB
testcase_03 AC 78 ms
76,364 KB
testcase_04 AC 291 ms
96,544 KB
testcase_05 AC 324 ms
94,076 KB
testcase_06 AC 229 ms
107,404 KB
testcase_07 AC 76 ms
76,364 KB
testcase_08 AC 148 ms
85,816 KB
testcase_09 AC 180 ms
90,036 KB
testcase_10 AC 191 ms
90,252 KB
testcase_11 AC 173 ms
87,304 KB
testcase_12 AC 97 ms
78,032 KB
testcase_13 AC 228 ms
91,972 KB
testcase_14 AC 255 ms
89,548 KB
testcase_15 AC 268 ms
93,644 KB
testcase_16 AC 211 ms
85,724 KB
testcase_17 AC 186 ms
88,356 KB
testcase_18 AC 230 ms
91,776 KB
testcase_19 AC 171 ms
87,852 KB
testcase_20 AC 138 ms
82,548 KB
testcase_21 AC 206 ms
96,924 KB
testcase_22 AC 243 ms
91,096 KB
testcase_23 AC 285 ms
109,352 KB
testcase_24 AC 316 ms
93,944 KB
testcase_25 AC 316 ms
94,432 KB
testcase_26 AC 292 ms
100,868 KB
testcase_27 AC 290 ms
99,248 KB
testcase_28 AC 301 ms
98,104 KB
testcase_29 AC 299 ms
109,356 KB
testcase_30 AC 308 ms
96,884 KB
testcase_31 AC 316 ms
95,768 KB
testcase_32 AC 327 ms
93,988 KB
testcase_33 AC 79 ms
75,740 KB
testcase_34 AC 79 ms
75,540 KB
testcase_35 AC 86 ms
76,240 KB
testcase_36 AC 87 ms
76,156 KB
testcase_37 AC 84 ms
75,844 KB
testcase_38 AC 80 ms
75,876 KB
testcase_39 AC 81 ms
75,920 KB
testcase_40 AC 79 ms
75,744 KB
testcase_41 AC 80 ms
75,844 KB
testcase_42 AC 79 ms
75,868 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