結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー 👑 KazunKazun
提出日時 2021-11-12 21:55:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,700 ms / 3,000 ms
コード長 1,051 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 121,444 KB
最終ジャッジ日時 2024-05-04 08:28:53
合計ジャッジ時間 23,392 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 39 ms
52,352 KB
testcase_02 AC 38 ms
52,992 KB
testcase_03 AC 39 ms
58,496 KB
testcase_04 AC 1,259 ms
103,088 KB
testcase_05 AC 1,649 ms
108,084 KB
testcase_06 AC 129 ms
97,024 KB
testcase_07 AC 44 ms
58,720 KB
testcase_08 AC 266 ms
93,604 KB
testcase_09 AC 287 ms
95,172 KB
testcase_10 AC 826 ms
85,008 KB
testcase_11 AC 105 ms
80,412 KB
testcase_12 AC 78 ms
76,032 KB
testcase_13 AC 124 ms
87,168 KB
testcase_14 AC 1,079 ms
98,788 KB
testcase_15 AC 884 ms
104,372 KB
testcase_16 AC 1,046 ms
84,864 KB
testcase_17 AC 516 ms
92,160 KB
testcase_18 AC 1,076 ms
87,072 KB
testcase_19 AC 191 ms
83,968 KB
testcase_20 AC 91 ms
78,464 KB
testcase_21 AC 445 ms
93,952 KB
testcase_22 AC 839 ms
100,444 KB
testcase_23 AC 1,387 ms
121,444 KB
testcase_24 AC 1,588 ms
107,568 KB
testcase_25 AC 1,571 ms
101,084 KB
testcase_26 AC 163 ms
96,384 KB
testcase_27 AC 1,666 ms
105,052 KB
testcase_28 AC 163 ms
97,064 KB
testcase_29 AC 1,700 ms
105,820 KB
testcase_30 AC 1,497 ms
119,024 KB
testcase_31 AC 159 ms
97,024 KB
testcase_32 AC 156 ms
96,632 KB
testcase_33 AC 62 ms
69,760 KB
testcase_34 AC 39 ms
57,472 KB
testcase_35 AC 37 ms
52,992 KB
testcase_36 AC 44 ms
61,056 KB
testcase_37 AC 40 ms
57,728 KB
testcase_38 AC 78 ms
76,288 KB
testcase_39 AC 68 ms
75,776 KB
testcase_40 AC 61 ms
68,732 KB
testcase_41 AC 74 ms
75,648 KB
testcase_42 AC 60 ms
69,632 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