結果

問題 No.1736 Princess vs. Dragoness
ユーザー gew1fw
提出日時 2025-06-12 13:47:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 76,472 KB
最終ジャッジ日時 2025-06-12 13:47:39
合計ジャッジ時間 4,287 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx]); idx +=1
    A = int(input[idx]); idx +=1
    B = int(input[idx]); idx +=1
    X = int(input[idx]); idx +=1
    Y = int(input[idx]); idx +=1
    H = list(map(int, input[idx:idx+N]))
    
    for i in range(N+1):
        # Calculate sum of A's needed for first i monsters
        sum_a = 0
        for j in range(i):
            sum_a += (H[j] + X - 1) // X
            if sum_a > A:
                break
        if sum_a > A:
            continue
        
        # Check remaining monsters
        remaining = H[i:]
        k = 0
        start = 0
        h = remaining.copy()
        possible = True
        while True:
            # Find the first alive monster from start
            while start < len(h) and h[start] <= 0:
                start += 1
            if start >= len(h):
                break
            k += 1
            if k > B:
                possible = False
                break
            P = Y
            current = start
            while current < len(h) and P > 0:
                if h[current] <= 0:
                    current += 1
                    continue
                d = min(P, h[current])
                h[current] -= d
                P -= d
                if h[current] == 0:
                    current += 1
            start = current
        
        if possible and k <= B:
            print("Yes")
            return
    
    print("No")

if __name__ == "__main__":
    main()
0