結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー moharan627moharan627
提出日時 2021-11-12 22:55:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 713 ms / 3,000 ms
コード長 1,654 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 114,252 KB
最終ジャッジ日時 2023-08-17 03:20:59
合計ジャッジ時間 16,838 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
71,516 KB
testcase_01 AC 98 ms
71,344 KB
testcase_02 AC 98 ms
71,204 KB
testcase_03 AC 100 ms
71,348 KB
testcase_04 AC 713 ms
99,832 KB
testcase_05 AC 268 ms
93,704 KB
testcase_06 AC 225 ms
114,252 KB
testcase_07 AC 98 ms
71,692 KB
testcase_08 AC 197 ms
85,992 KB
testcase_09 AC 228 ms
91,284 KB
testcase_10 AC 321 ms
94,600 KB
testcase_11 AC 263 ms
83,296 KB
testcase_12 AC 114 ms
77,340 KB
testcase_13 AC 465 ms
95,312 KB
testcase_14 AC 225 ms
90,276 KB
testcase_15 AC 706 ms
95,600 KB
testcase_16 AC 257 ms
83,424 KB
testcase_17 AC 388 ms
86,832 KB
testcase_18 AC 177 ms
86,384 KB
testcase_19 AC 382 ms
98,788 KB
testcase_20 AC 145 ms
81,756 KB
testcase_21 AC 599 ms
103,456 KB
testcase_22 AC 632 ms
92,972 KB
testcase_23 AC 697 ms
109,888 KB
testcase_24 AC 298 ms
95,332 KB
testcase_25 AC 245 ms
93,320 KB
testcase_26 AC 683 ms
104,512 KB
testcase_27 AC 240 ms
93,348 KB
testcase_28 AC 707 ms
96,584 KB
testcase_29 AC 270 ms
94,248 KB
testcase_30 AC 709 ms
103,380 KB
testcase_31 AC 679 ms
102,672 KB
testcase_32 AC 266 ms
94,384 KB
testcase_33 AC 106 ms
76,928 KB
testcase_34 AC 96 ms
71,780 KB
testcase_35 AC 106 ms
76,872 KB
testcase_36 AC 99 ms
71,456 KB
testcase_37 AC 98 ms
71,584 KB
testcase_38 AC 110 ms
76,740 KB
testcase_39 AC 113 ms
76,564 KB
testcase_40 AC 109 ms
76,940 KB
testcase_41 AC 109 ms
76,828 KB
testcase_42 AC 109 ms
76,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20,2**63に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LC(): return list(input())
def IC(): return [int(c) for c in input()]
def MI(): return map(int, sys.stdin.readline().split())
N,A,B,X,Y = MI()
H =LI()
def is_ok(K):
    # 条件を満たすかどうか?問題ごとに定義
    a,b,x,y = A,B,X,Y
    HP = [0]*N
    for n in range(N):
        HP[n] = H[n]-K
    for n in range(N):
        if(HP[n]<=0):
            continue
        atk = HP[n]//x
        at = min(atk,a)
        HP[n] -=at*x
        a-=at
    if 0<a:
        HP.sort(reverse=True)
        for n in range(min(N,a)):
            HP[n] = 0
    SUM = 0
    for h in HP:
        if h<=0:
            continue
        else:
            SUM += h
    return SUM <= b*y
def meguru_bisect(ng, ok):
    """
    この条件は、問題に基づくやつじゃなくてもOK
    条件の付け方は、ngとokの広げ方をどのようにするかで決まってくる。
    (目的値)~正の無限 が条件を満たす場合
    ng…条件を満たさない値の範囲での最大値
    ok…条件を満たす値の範囲での最小値
    ng < ok
    is_ok == Trueの場合、探索範囲が左半分へ
    is_ok == Falseの場合、探索範囲が右半分へ
    """
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(meguru_bisect(-1,10**9))
0