結果

問題 No.2328 Build Walls
ユーザー sepa38sepa38
提出日時 2023-04-13 10:37:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 449 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 87,616 KB
最終ジャッジ日時 2024-04-17 15:36:16
合計ジャッジ時間 5,401 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
52,632 KB
testcase_01 AC 34 ms
52,860 KB
testcase_02 AC 29 ms
52,444 KB
testcase_03 AC 29 ms
52,788 KB
testcase_04 AC 30 ms
53,208 KB
testcase_05 AC 29 ms
52,684 KB
testcase_06 AC 30 ms
53,484 KB
testcase_07 AC 29 ms
53,412 KB
testcase_08 AC 29 ms
52,488 KB
testcase_09 AC 29 ms
52,544 KB
testcase_10 AC 30 ms
52,468 KB
testcase_11 AC 29 ms
52,548 KB
testcase_12 AC 30 ms
53,388 KB
testcase_13 AC 98 ms
80,432 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 47 ms
71,616 KB
testcase_20 WA -
testcase_21 AC 77 ms
81,176 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 96 ms
81,264 KB
testcase_29 WA -
testcase_30 AC 126 ms
86,856 KB
testcase_31 AC 121 ms
86,928 KB
testcase_32 WA -
testcase_33 AC 150 ms
87,132 KB
testcase_34 AC 129 ms
87,344 KB
testcase_35 AC 149 ms
86,968 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h-2)]
inf = 1 << 30
dp = [[inf] * (h - 2) for _ in range(w)]
for i in range(h-2):
  if a[i][0] == -1:
    continue
  dp[0][i] = a[i][0]
for j in range(1, w):
  for i in range(h-2):
    if a[i][j] == -1:
      continue
    for k in range(max(0, i-1), min(h-2, i+2)):
      dp[j][i] = min(dp[j][i], dp[j-1][k]+a[i][j])
print(min(dp[-1]) if min(dp[-1]) < inf else -1)
0