結果

問題 No.2095 High Rise
ユーザー ニックネームニックネーム
提出日時 2022-10-07 22:17:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,736 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 103,884 KB
最終ジャッジ日時 2023-09-03 13:11:23
合計ジャッジ時間 12,319 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,884 KB
testcase_01 AC 16 ms
7,884 KB
testcase_02 AC 16 ms
7,988 KB
testcase_03 AC 16 ms
7,868 KB
testcase_04 AC 16 ms
7,876 KB
testcase_05 AC 16 ms
7,812 KB
testcase_06 AC 16 ms
7,980 KB
testcase_07 AC 16 ms
7,860 KB
testcase_08 AC 16 ms
7,976 KB
testcase_09 AC 16 ms
7,824 KB
testcase_10 AC 16 ms
7,832 KB
testcase_11 AC 16 ms
7,972 KB
testcase_12 AC 21 ms
8,312 KB
testcase_13 AC 19 ms
8,304 KB
testcase_14 AC 27 ms
8,824 KB
testcase_15 AC 21 ms
8,360 KB
testcase_16 AC 19 ms
8,228 KB
testcase_17 AC 200 ms
18,692 KB
testcase_18 AC 140 ms
15,320 KB
testcase_19 AC 44 ms
9,856 KB
testcase_20 AC 212 ms
19,616 KB
testcase_21 AC 397 ms
30,508 KB
testcase_22 AC 1,730 ms
103,588 KB
testcase_23 AC 1,669 ms
103,712 KB
testcase_24 AC 1,681 ms
103,884 KB
testcase_25 AC 1,650 ms
103,680 KB
testcase_26 AC 1,736 ms
103,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
dp = [a[0]]+[[] for _ in range(n-1)]
b = [min(a[0])]+[10**15]*(n-1)
for i in range(n-1):
    for j in range(m):
        dp[i+1].append(min(b[i]+a[i][j]+a[i+1][j], dp[i][j]+a[i+1][j]))
        b[i+1] = min(b[i+1], dp[i+1][j])
print(b[-1] if n > 1 else 0)
0