結果

問題 No.1736 Princess vs. Dragoness
ユーザー Shirapon_pon
提出日時 2021-11-15 11:40:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 71,612 KB
最終ジャッジ日時 2025-07-04 14:05:57
合計ジャッジ時間 3,475 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

n, a, b, x, y = map(int, input().split())
h = [int(i) for i in input().split()]
h.sort()

def magicA():
    for i in range(n):
        if h[n-i-1] > 0:
            h[n-i-1] -= x
            break
    h.sort()

def magicB():
    p = y
    i = 0
    while p > 0 and i < n:
        if h[i] > 0:
            d = min(p,h[i])
            h[i] -= d
            p -= d
        i += 1

def check():
    if max(h) <= 0:
        return True
    return False

def is_clear():
    if check():
        print("Yes")
    else:
        print("No")

while not(check()) and a > 0:
    magicA()
    a -= 1
while not(check()) and b > 0:
    magicB()
    b -= 1
is_clear()
0