結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,060 KB
testcase_01 AC 74 ms
71,392 KB
testcase_02 AC 76 ms
71,148 KB
testcase_03 AC 75 ms
71,384 KB
testcase_04 AC 75 ms
71,204 KB
testcase_05 AC 73 ms
71,148 KB
testcase_06 AC 74 ms
71,220 KB
testcase_07 AC 75 ms
71,196 KB
testcase_08 AC 74 ms
71,160 KB
testcase_09 AC 73 ms
71,020 KB
testcase_10 AC 73 ms
71,144 KB
testcase_11 AC 71 ms
71,352 KB
testcase_12 AC 72 ms
71,404 KB
testcase_13 AC 159 ms
80,192 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 105 ms
78,444 KB
testcase_20 WA -
testcase_21 AC 138 ms
82,740 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 155 ms
82,292 KB
testcase_29 WA -
testcase_30 AC 203 ms
88,288 KB
testcase_31 AC 198 ms
88,496 KB
testcase_32 WA -
testcase_33 AC 219 ms
92,464 KB
testcase_34 AC 208 ms
88,412 KB
testcase_35 AC 228 ms
91,536 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(1,H):
        if A[i][j] == -1: continue
        tmp = min(dp[i-1][j-1], dp[i][j-1], dp[i+1][j-1])
        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