結果

問題 No.2095 High Rise
ユーザー tnogamitnogami
提出日時 2022-10-08 20:42:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,316 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 103,036 KB
最終ジャッジ日時 2023-09-05 02:13:50
合計ジャッジ時間 11,338 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 15 ms
7,812 KB
testcase_03 AC 15 ms
7,876 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,848 KB
testcase_06 AC 16 ms
7,948 KB
testcase_07 AC 16 ms
7,792 KB
testcase_08 AC 16 ms
7,888 KB
testcase_09 AC 16 ms
7,852 KB
testcase_10 AC 16 ms
7,952 KB
testcase_11 AC 16 ms
7,796 KB
testcase_12 AC 19 ms
8,212 KB
testcase_13 AC 19 ms
8,416 KB
testcase_14 AC 23 ms
8,516 KB
testcase_15 AC 20 ms
8,400 KB
testcase_16 AC 18 ms
8,356 KB
testcase_17 AC 153 ms
18,876 KB
testcase_18 AC 109 ms
15,228 KB
testcase_19 AC 38 ms
9,752 KB
testcase_20 AC 169 ms
19,696 KB
testcase_21 AC 305 ms
30,256 KB
testcase_22 AC 1,316 ms
103,036 KB
testcase_23 AC 1,282 ms
102,820 KB
testcase_24 AC 1,265 ms
102,996 KB
testcase_25 AC 1,274 ms
102,976 KB
testcase_26 AC 1,300 ms
102,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

dp = [[10**19]*M for _ in range(N+1)]

for i, a in enumerate(A[0]):
    dp[1][i] = a

minimum = min(dp[1])

for n in range(1,N):
    mini = min(dp[n])
    for m in range(M):
        if dp[n][m] == mini:
            dp[n+1][m] = mini + A[n][m]
        else:
            dp[n+1][m] = min(dp[n][m]+A[n][m], mini+A[n-1][m]+A[n][m])

if N == 1:
    print(0)
else:
    print(min(dp[N]))
0