結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー abababab
提出日時 2022-05-21 00:07:27
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 103,748 KB
最終ジャッジ日時 2023-10-20 15:01:57
合計ジャッジ時間 5,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,552 KB
testcase_01 AC 35 ms
53,552 KB
testcase_02 AC 35 ms
53,552 KB
testcase_03 AC 37 ms
53,552 KB
testcase_04 AC 35 ms
53,552 KB
testcase_05 AC 35 ms
53,552 KB
testcase_06 AC 35 ms
53,552 KB
testcase_07 AC 178 ms
103,524 KB
testcase_08 AC 167 ms
103,512 KB
testcase_09 AC 187 ms
103,576 KB
testcase_10 AC 185 ms
103,712 KB
testcase_11 AC 179 ms
103,448 KB
testcase_12 WA -
testcase_13 AC 175 ms
103,688 KB
testcase_14 AC 176 ms
103,688 KB
testcase_15 AC 169 ms
103,612 KB
testcase_16 AC 51 ms
63,988 KB
testcase_17 AC 60 ms
68,520 KB
testcase_18 AC 37 ms
53,560 KB
testcase_19 AC 37 ms
53,560 KB
testcase_20 AC 179 ms
103,632 KB
testcase_21 AC 189 ms
103,604 KB
testcase_22 AC 165 ms
103,748 KB
testcase_23 AC 161 ms
103,596 KB
testcase_24 AC 166 ms
103,628 KB
testcase_25 AC 175 ms
102,580 KB
testcase_26 AC 182 ms
103,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(h)]

DXY = [(0, 1), (1, 0)]

dp = [[[0] * 2 for _ in range(w)] for _ in range(h)]
dp[0][0][0] = A[0][0]

for i in range(h):
    for j in range(w):
        a = dp[i][j][0]
        for di, dj in DXY:
            ni, nj = i + di, j + dj
            if not (0 <= ni < h and 0 <= nj < w):
                continue
            enemy = A[ni][nj]
            if a > enemy:
                dp[ni][nj][0] = max(dp[ni][nj][0], a + enemy)
            else:
                if dp[ni][nj][1]:
                    continue
                dp[ni][nj][1] = max(dp[ni][nj][0], a)

        a = dp[i][j][1]
        for di, dj in DXY:
            ni, nj = i + di, j + dj
            if not (0 <= ni < h and 0 <= nj < w):
                continue
            enemy = A[ni][nj]
            if a > enemy:
                dp[ni][nj][1] = max(dp[ni][nj][1], a + enemy)

ans = max(dp[-1][-1])
print('Yes' if ans not in (0, A[-1][-1]) else 'No')
0