結果

問題 No.1736 Princess vs. Dragoness
ユーザー lam6er
提出日時 2025-03-31 17:56:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 76,496 KB
最終ジャッジ日時 2025-03-31 17:57:58
合計ジャッジ時間 3,802 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve():
    N, A, B, X, Y = map(int, sys.stdin.readline().split())
    H = list(map(int, sys.stdin.readline().split()))
    
    for k in range(N+1):
        sum_a = 0
        valid = True
        for i in range(k):
            need = (H[i] + X - 1) // X
            sum_a += need
            if sum_a > A:
                valid = False
                break
        if not valid:
            continue
        
        required_b = 0
        current = 0  # Remaining damage from previous B
        for i in range(k, N):
            h = H[i]
            if current >= h:
                current -= h
                continue
            else:
                h -= current
                current = 0
                full = h // Y
                rem = h % Y
                required_b += full
                if rem > 0:
                    required_b += 1
                    current = Y - rem
                else:
                    current = 0
        if required_b <= B:
            print("Yes")
            return
    print("No")

solve()
0