結果

問題 No.2922 Rose Garden
ユーザー 学ぶマン学ぶマン
提出日時 2024-10-14 15:42:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,915 ms / 3,000 ms
コード長 1,264 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,392 KB
最終ジャッジ日時 2024-10-14 15:42:51
合計ジャッジ時間 29,937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 428 ms
93,056 KB
testcase_01 AC 238 ms
82,176 KB
testcase_02 AC 1,116 ms
93,056 KB
testcase_03 AC 1,221 ms
107,392 KB
testcase_04 AC 898 ms
92,800 KB
testcase_05 AC 437 ms
90,368 KB
testcase_06 AC 475 ms
81,884 KB
testcase_07 AC 1,416 ms
100,608 KB
testcase_08 AC 381 ms
74,752 KB
testcase_09 AC 474 ms
103,936 KB
testcase_10 AC 69 ms
77,440 KB
testcase_11 AC 416 ms
74,368 KB
testcase_12 AC 409 ms
93,056 KB
testcase_13 AC 758 ms
97,792 KB
testcase_14 AC 251 ms
73,216 KB
testcase_15 AC 1,824 ms
90,752 KB
testcase_16 AC 1,164 ms
97,536 KB
testcase_17 AC 970 ms
104,064 KB
testcase_18 AC 243 ms
68,224 KB
testcase_19 AC 1,218 ms
87,168 KB
testcase_20 AC 1,230 ms
95,224 KB
testcase_21 AC 1,461 ms
103,680 KB
testcase_22 AC 137 ms
90,732 KB
testcase_23 AC 207 ms
100,584 KB
testcase_24 AC 259 ms
73,472 KB
testcase_25 AC 164 ms
88,960 KB
testcase_26 AC 1,915 ms
95,284 KB
testcase_27 AC 1,805 ms
97,920 KB
testcase_28 AC 299 ms
95,272 KB
testcase_29 AC 1,737 ms
92,732 KB
testcase_30 AC 56 ms
63,616 KB
testcase_31 AC 55 ms
62,720 KB
testcase_32 AC 69 ms
64,768 KB
testcase_33 AC 53 ms
62,976 KB
testcase_34 AC 58 ms
65,152 KB
testcase_35 AC 62 ms
63,360 KB
testcase_36 AC 96 ms
68,096 KB
testcase_37 AC 52 ms
66,304 KB
testcase_38 AC 51 ms
63,360 KB
testcase_39 AC 63 ms
65,920 KB
testcase_40 AC 1,044 ms
95,324 KB
testcase_41 AC 68 ms
79,488 KB
testcase_42 AC 462 ms
107,328 KB
testcase_43 AC 237 ms
87,296 KB
testcase_44 AC 373 ms
104,168 KB
testcase_45 AC 171 ms
74,880 KB
testcase_46 AC 115 ms
101,248 KB
testcase_47 AC 108 ms
95,216 KB
testcase_48 AC 60 ms
72,320 KB
testcase_49 AC 115 ms
101,052 KB
testcase_50 AC 38 ms
52,096 KB
testcase_51 AC 39 ms
51,968 KB
testcase_52 AC 38 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
inf = 1<<60
N, S, B = map(int, sys.stdin.readline().rstrip().split())
H = list(map(int, sys.stdin.readline().rstrip().split()))

def kiriage(a, b):
    return (a+b-1)//b

def chmax(DP,i,v):
    if DP[i] < v:
        DP[i] = v

def chmin(DP,i,v):
    if DP[i] > v:
        DP[i] = v

DP = [-1] * (S + 1)
DP[S] = H[0]
# DP[stamina] stamina で到達できる max height

# in-place でやる
for i in range(N - 1): # N - 1 ターン

    landing = False

    for j in range(S + 1): # j: stamina DP[j]: height

        if DP[j] == -1:
            continue

        # 今いる高さ -> 次の足場の高低差
        diff = max(0, H[i + 1] - DP[j])

        cost = kiriage(diff, B)
        # stamina==j から cost を捻出できるか?
        if j >= cost:
            chmax(DP, j - cost, DP[j] + cost * B)
            # 捻出できる=次の足場上に浮いていられる
            landing = True
        # 捻出できないなら その高さ・スタミナからは到達不能

    if landing:
        # 足場 H[i + 1] に着地した場合のステータスも考慮
        DP[S] = max(DP[S], H[i + 1])

    else: #途中経過でlanding できない足場があったらその時点で詰み
        exit(print('No'))

print('Yes')
0