結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-05-20 21:39:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 122,048 KB
最終ジャッジ日時 2023-10-20 12:04:08
合計ジャッジ時間 5,624 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,464 KB
testcase_01 AC 44 ms
55,464 KB
testcase_02 AC 46 ms
55,464 KB
testcase_03 AC 46 ms
55,464 KB
testcase_04 AC 42 ms
55,464 KB
testcase_05 AC 42 ms
55,464 KB
testcase_06 AC 43 ms
55,464 KB
testcase_07 AC 202 ms
107,140 KB
testcase_08 AC 173 ms
100,056 KB
testcase_09 AC 233 ms
118,244 KB
testcase_10 AC 224 ms
115,712 KB
testcase_11 AC 207 ms
100,832 KB
testcase_12 AC 211 ms
103,344 KB
testcase_13 AC 221 ms
103,240 KB
testcase_14 AC 211 ms
103,412 KB
testcase_15 AC 184 ms
100,400 KB
testcase_16 AC 54 ms
66,284 KB
testcase_17 AC 56 ms
66,212 KB
testcase_18 AC 44 ms
55,464 KB
testcase_19 AC 44 ms
55,464 KB
testcase_20 AC 233 ms
113,208 KB
testcase_21 AC 239 ms
112,292 KB
testcase_22 AC 174 ms
100,252 KB
testcase_23 AC 166 ms
100,224 KB
testcase_24 AC 214 ms
115,140 KB
testcase_25 AC 251 ms
117,220 KB
testcase_26 AC 262 ms
122,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

import sys
from sys import stdin
from collections import deque

H,W = map(int,stdin.readline().split())

A = [ list(map(int,stdin.readline().split())) for i in range(H) ]

dp = [[[float("-inf"),float("-inf")] for j in range(W)] for i in range(H)]

dp[0][0][0] = A[0][0]

for i in range(H):

    for j in range(W):

        for k in range(2):

            now = dp[i][j][k]
            if i != H-1:

                if A[i+1][j] < now:
                    dp[i+1][j][k] = max(dp[i+1][j][k] , now+A[i+1][j])
                if k == 0 and (i+1,j) != (H-1,W-1):
                    dp[i+1][j][1] = max(dp[i+1][j][1] , now)

            if j != W-1:

                if A[i][j+1] < now:
                    dp[i][j+1][k] = max(dp[i][j+1][k] , now+A[i][j+1])
                if k == 0 and (i,j+1) != (H-1,W-1):
                    dp[i][j+1][1] = max(dp[i][j+1][1] , now)

#print (dp)

if dp[-1][-1][0] != float("-inf") or dp[-1][-1][1] != float("-inf"):
    print ("Yes")
else:
    print ("No")
0