結果

問題 No.2095 High Rise
ユーザー ああいいああいい
提出日時 2022-10-08 22:06:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 86,940 KB
最終ジャッジ日時 2023-09-05 03:25:14
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,568 KB
testcase_01 AC 76 ms
71,316 KB
testcase_02 AC 76 ms
71,280 KB
testcase_03 AC 76 ms
71,348 KB
testcase_04 AC 75 ms
71,228 KB
testcase_05 AC 76 ms
71,224 KB
testcase_06 AC 76 ms
71,300 KB
testcase_07 AC 76 ms
71,120 KB
testcase_08 AC 75 ms
71,364 KB
testcase_09 AC 77 ms
71,528 KB
testcase_10 AC 77 ms
71,312 KB
testcase_11 AC 78 ms
71,252 KB
testcase_12 AC 130 ms
76,824 KB
testcase_13 AC 87 ms
76,448 KB
testcase_14 AC 86 ms
76,688 KB
testcase_15 AC 87 ms
76,592 KB
testcase_16 AC 84 ms
76,416 KB
testcase_17 AC 108 ms
77,936 KB
testcase_18 AC 104 ms
77,888 KB
testcase_19 AC 88 ms
76,524 KB
testcase_20 AC 108 ms
77,560 KB
testcase_21 AC 125 ms
81,320 KB
testcase_22 AC 238 ms
86,832 KB
testcase_23 AC 235 ms
86,940 KB
testcase_24 AC 235 ms
86,772 KB
testcase_25 AC 238 ms
86,720 KB
testcase_26 AC 238 ms
86,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


import sys
if N == 1:
    print(0)
    exit()
inf = 10 ** 15
dp = [[inf] * M for _ in range(N)]

for i in range(M):
    dp[0][i] = A[0][i]
for i in range(1,N):
    s = min(dp[i-1])
    for j in range(M):
        dp[i][j] = min(dp[i-1][j] + A[i][j],s + A[i][j] + A[i-1][j])
ans = inf
for j in range(M):
    if dp[-1][j] < ans:
        ans = dp[-1][j]
print(ans)
0