結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー first_vilfirst_vil
提出日時 2022-05-20 22:13:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 1,247 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 83,136 KB
最終ジャッジ日時 2023-10-20 12:55:58
合計ジャッジ時間 4,259 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,496 KB
testcase_01 AC 37 ms
53,496 KB
testcase_02 AC 41 ms
53,496 KB
testcase_03 AC 37 ms
53,496 KB
testcase_04 AC 40 ms
53,496 KB
testcase_05 AC 40 ms
53,496 KB
testcase_06 AC 38 ms
53,496 KB
testcase_07 AC 124 ms
82,080 KB
testcase_08 AC 114 ms
81,944 KB
testcase_09 AC 130 ms
82,044 KB
testcase_10 AC 130 ms
82,064 KB
testcase_11 AC 144 ms
82,344 KB
testcase_12 AC 151 ms
83,136 KB
testcase_13 AC 156 ms
82,872 KB
testcase_14 AC 144 ms
82,972 KB
testcase_15 AC 130 ms
82,824 KB
testcase_16 AC 52 ms
64,096 KB
testcase_17 AC 50 ms
64,092 KB
testcase_18 AC 40 ms
53,496 KB
testcase_19 AC 39 ms
53,496 KB
testcase_20 AC 163 ms
82,884 KB
testcase_21 AC 163 ms
82,876 KB
testcase_22 AC 109 ms
82,036 KB
testcase_23 AC 108 ms
81,940 KB
testcase_24 AC 133 ms
82,188 KB
testcase_25 AC 162 ms
82,608 KB
testcase_26 AC 168 ms
82,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353


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


h, w = mi()
a = [li() for _ in range(h)]
dp = [[[0] * w for i in range(h)] for k in range(2)]
dp[0][0][0] = a[0][0]
for k in range(2):
    for i in range(h):
        for j in range(w):
            if i + 1 < h:
                if k == 0 and (i + 1 != h - 1 or j != w - 1):
                    chmax(dp[1][i + 1], j, dp[k][i][j])
                if a[i + 1][j] < dp[k][i][j]:
                    chmax(dp[k][i + 1], j, dp[k][i][j] + a[i + 1][j])
            if j + 1 < w:
                if k == 0 and (i != h - 1 or j + 1 != w - 1):
                    chmax(dp[1][i], j + 1, dp[k][i][j])
                if a[i][j + 1] < dp[k][i][j]:
                    chmax(dp[k][i], j + 1, dp[k][i][j] + a[i][j + 1])
print("Yes" if 0 < max(dp[0][-1][-1], dp[1][-1][-1]) else "No")
0