結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー 👑 H20H20
提出日時 2022-04-02 20:22:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 102,976 KB
最終ジャッジ日時 2023-09-09 03:31:53
合計ジャッジ時間 7,577 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,176 KB
testcase_01 AC 72 ms
71,276 KB
testcase_02 AC 72 ms
71,236 KB
testcase_03 AC 72 ms
71,072 KB
testcase_04 AC 72 ms
71,348 KB
testcase_05 AC 71 ms
71,224 KB
testcase_06 AC 71 ms
71,452 KB
testcase_07 AC 203 ms
101,456 KB
testcase_08 AC 187 ms
101,960 KB
testcase_09 AC 208 ms
102,144 KB
testcase_10 AC 187 ms
102,244 KB
testcase_11 AC 214 ms
101,812 KB
testcase_12 AC 216 ms
102,908 KB
testcase_13 AC 247 ms
102,976 KB
testcase_14 AC 235 ms
102,960 KB
testcase_15 AC 205 ms
102,752 KB
testcase_16 AC 78 ms
71,404 KB
testcase_17 AC 87 ms
71,192 KB
testcase_18 AC 76 ms
71,392 KB
testcase_19 AC 73 ms
71,292 KB
testcase_20 AC 236 ms
102,892 KB
testcase_21 AC 228 ms
102,324 KB
testcase_22 AC 163 ms
91,936 KB
testcase_23 AC 165 ms
92,104 KB
testcase_24 AC 177 ms
92,504 KB
testcase_25 AC 215 ms
102,220 KB
testcase_26 AC 231 ms
102,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
DP = [[[0]*2 for _ in range(W)]for _ in range(H)]
DP[0][0][0]=A[0][0]
for h in range(H):
    for w in range(W):
        if h+1<H and DP[h][w][0]>A[h+1][w]:
            DP[h+1][w][0]=max(DP[h+1][w][0],DP[h][w][0]+A[h+1][w])
        if w+1<W and DP[h][w][0]>A[h][w+1]:
            DP[h][w+1][0]=max(DP[h][w+1][0],DP[h][w][0]+A[h][w+1])
        if h+1<H and DP[h][w][1]>A[h+1][w]:
            DP[h+1][w][1]=max(DP[h+1][w][1],DP[h][w][1]+A[h+1][w])
        if w+1<W and DP[h][w][1]>A[h][w+1]:
            DP[h][w+1][1]=max(DP[h][w+1][1],DP[h][w][1]+A[h][w+1])
        if h+1<H and DP[h][w][0]<=A[h+1][w]:
            DP[h+1][w][1]=max(DP[h+1][w][1],DP[h][w][0])
        if w+1<W and DP[h][w][0]<=A[h][w+1]:
            DP[h][w+1][1]=max(DP[h][w+1][1],DP[h][w][0])
if max(DP[H-1][W-1])>A[H-1][W-1]:
    print('Yes')
else:
    print('No')
0