結果

問題 No.1736 Princess vs. Dragoness
ユーザー flippergo
提出日時 2024-12-29 11:10:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,044 KB
最終ジャッジ日時 2024-12-29 11:10:56
合計ジャッジ時間 4,619 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,A,B,X,Y = map(int,input().split())
H = list(map(int,input().split()))
heap = []
for i in range(N):
    heapq.heappush(heap,-H[i])
cnt = 0
while heap and cnt<A:
    h = -heapq.heappop(heap)
    h -= X
    cnt += 1
    if h>0:
        heapq.heappush(heap,-h)
for _ in range(B):
    p = Y
    A = []
    while p>0 and heap:
        h = -heapq.heappop(heap)
        d = min(h,p)
        h -= d
        p -= d
        if h>0:
            A.append(h)
    for a in A:
        heapq.heappush(heap,-a)
if heap:
    print("No")
else:
    print("Yes")
0