結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー 👑 KazunKazun
提出日時 2021-11-12 21:55:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,040 ms / 3,000 ms
コード長 1,051 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 86,644 KB
実行使用メモリ 122,668 KB
最終ジャッジ日時 2023-08-17 01:13:50
合計ジャッジ時間 28,916 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,404 KB
testcase_01 AC 78 ms
71,268 KB
testcase_02 AC 75 ms
71,408 KB
testcase_03 AC 79 ms
75,024 KB
testcase_04 AC 1,452 ms
103,816 KB
testcase_05 AC 2,005 ms
108,400 KB
testcase_06 AC 159 ms
92,056 KB
testcase_07 AC 76 ms
75,132 KB
testcase_08 AC 311 ms
94,764 KB
testcase_09 AC 349 ms
97,716 KB
testcase_10 AC 942 ms
86,612 KB
testcase_11 AC 148 ms
81,692 KB
testcase_12 AC 113 ms
77,636 KB
testcase_13 AC 167 ms
89,004 KB
testcase_14 AC 1,293 ms
100,244 KB
testcase_15 AC 1,001 ms
105,540 KB
testcase_16 AC 1,200 ms
86,288 KB
testcase_17 AC 629 ms
93,252 KB
testcase_18 AC 1,254 ms
88,700 KB
testcase_19 AC 252 ms
85,352 KB
testcase_20 AC 131 ms
80,172 KB
testcase_21 AC 534 ms
94,796 KB
testcase_22 AC 1,030 ms
102,332 KB
testcase_23 AC 1,676 ms
122,668 KB
testcase_24 AC 1,837 ms
108,744 KB
testcase_25 AC 1,910 ms
102,096 KB
testcase_26 AC 197 ms
91,652 KB
testcase_27 AC 2,040 ms
105,836 KB
testcase_28 AC 195 ms
91,444 KB
testcase_29 AC 1,952 ms
107,116 KB
testcase_30 AC 1,712 ms
120,272 KB
testcase_31 AC 194 ms
91,500 KB
testcase_32 AC 204 ms
91,760 KB
testcase_33 AC 102 ms
77,472 KB
testcase_34 AC 77 ms
75,228 KB
testcase_35 AC 76 ms
71,332 KB
testcase_36 AC 82 ms
76,656 KB
testcase_37 AC 75 ms
75,012 KB
testcase_38 AC 111 ms
77,224 KB
testcase_39 AC 103 ms
76,976 KB
testcase_40 AC 97 ms
76,360 KB
testcase_41 AC 110 ms
77,360 KB
testcase_42 AC 102 ms
77,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def General_Binary_Increase_Search_Integer(L,R,cond,default=None):
    """条件式が単調増加であるとき, 整数上で二部探索を行う.
    L: 解の下限
    R: 解の上限
    cond: 条件(1変数関数, 広義単調増加を満たす)
    default: Lで条件を満たさないときの返り値
    """
    if not(cond(R)): return default

    if cond(L): return L

    R+=1
    while R-L>1:
        C=L+(R-L)//2
        if cond(C): R=C
        else: L=C
    return R
#==================================================
from heapq import heapify,heappop,heappush

def checks(K,N,A,B,X,Y,H):
    HH=[-(hp-K) for hp in H if hp>K]
    heapify(HH)

    for _ in range(A):
        if not HH:
            continue

        hp=-heappop(HH)
        if hp>=X:
            heappush(HH,-(hp-X))
    return -sum(HH)<=Y*B
#==================================================
N,A,B,X,Y=map(int,input().split())
H=list(map(int,input().split()))

check=lambda K:checks(K,N,A,B,X,Y,H)
print(General_Binary_Increase_Search_Integer(0,max(H),check,-1))
0