結果

問題 No.2328 Build Walls
ユーザー prd_xxxprd_xxx
提出日時 2023-05-28 15:56:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 92,648 KB
最終ジャッジ日時 2023-08-27 13:22:32
合計ジャッジ時間 7,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,392 KB
testcase_01 AC 73 ms
71,468 KB
testcase_02 AC 74 ms
71,360 KB
testcase_03 AC 75 ms
71,324 KB
testcase_04 AC 72 ms
71,396 KB
testcase_05 AC 73 ms
71,024 KB
testcase_06 AC 73 ms
71,300 KB
testcase_07 AC 76 ms
71,512 KB
testcase_08 AC 74 ms
71,320 KB
testcase_09 AC 74 ms
71,336 KB
testcase_10 AC 74 ms
71,220 KB
testcase_11 AC 73 ms
71,068 KB
testcase_12 AC 73 ms
71,264 KB
testcase_13 AC 166 ms
80,120 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 105 ms
78,324 KB
testcase_20 WA -
testcase_21 AC 135 ms
82,628 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 157 ms
82,564 KB
testcase_29 WA -
testcase_30 AC 211 ms
88,296 KB
testcase_31 AC 201 ms
88,228 KB
testcase_32 WA -
testcase_33 AC 218 ms
92,648 KB
testcase_34 AC 204 ms
88,296 KB
testcase_35 AC 232 ms
91,724 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
A = []
A.append([-1]*W)
for _ in range(H-2):
    A.append(list(map(int,input().split())))
A.append([-1]*W)

INF = float('inf')
dp = [[INF]*W for _ in range(H)]
for i in range(H):
    if A[i][0] == -1: continue
    dp[i][0] = A[i][0]

for j in range(1,W):
    for i in range(H):
        if A[i][j] == -1: continue
        tmp = min(dp[i-1][j-1], dp[i][j-1], dp[i+1][j-1])
        if tmp == INF: continue
        dp[i][j] = tmp + A[i][j]

ans = INF
for i in range(H):
    ans = min(ans, dp[i][-1])
print(-1 if ans==INF else ans)
0