結果

問題 No.2922 Rose Garden
ユーザー prd_xxx
提出日時 2024-10-12 14:53:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 3,000 ms
コード長 501 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 107,136 KB
最終ジャッジ日時 2024-10-12 14:53:29
合計ジャッジ時間 8,771 ms
ジャッジサーバーID
(参考情報)
judge5 / judge
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S,B = map(int,input().split())
H = list(map(int,input().split()))

dp = {S:H[0]}
for i in range(1,N):
    ndp = {}
    for s,h in dp.items():
        need = max(0,H[i]-h)
        k = 0--need//B
        if k > s: continue
        ns = s-k
        nh = h + k*B
        if ns in ndp:
            ndp[ns] = max(ndp[ns],nh)
        else:
            ndp[ns] = nh
        if S in ndp:
            ndp[S] = max(ndp[S],H[i])
        else:
            ndp[S] = H[i]
    dp = ndp

print('Yes' if dp else 'No')
0