結果

問題 No.2095 High Rise
ユーザー pitPpitP
提出日時 2022-10-08 08:52:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 86,760 KB
最終ジャッジ日時 2023-09-04 07:33:12
合計ジャッジ時間 7,757 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,332 KB
testcase_01 AC 72 ms
71,444 KB
testcase_02 AC 73 ms
71,392 KB
testcase_03 AC 73 ms
71,048 KB
testcase_04 AC 75 ms
71,472 KB
testcase_05 AC 73 ms
71,240 KB
testcase_06 AC 77 ms
71,164 KB
testcase_07 AC 78 ms
71,124 KB
testcase_08 AC 76 ms
71,092 KB
testcase_09 AC 78 ms
71,368 KB
testcase_10 AC 77 ms
71,376 KB
testcase_11 AC 77 ms
70,936 KB
testcase_12 AC 88 ms
76,492 KB
testcase_13 AC 80 ms
76,484 KB
testcase_14 AC 82 ms
76,416 KB
testcase_15 AC 81 ms
76,288 KB
testcase_16 AC 84 ms
76,236 KB
testcase_17 AC 109 ms
77,552 KB
testcase_18 AC 104 ms
77,564 KB
testcase_19 AC 88 ms
76,452 KB
testcase_20 AC 106 ms
77,504 KB
testcase_21 AC 129 ms
81,128 KB
testcase_22 AC 236 ms
86,504 KB
testcase_23 AC 236 ms
86,760 KB
testcase_24 AC 242 ms
86,724 KB
testcase_25 AC 233 ms
86,684 KB
testcase_26 AC 234 ms
86,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1<<60


N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
    print(0)
    exit()

dp = [[INF] * M for _ in range(N)]
val = INF
for j in range(M):
    dp[1][j] = A[0][j] + A[1][j]
    val = min(val , dp[1][j])

for i in range(2,N):
    nxt_val = INF
    for j in range(M):
        dp[i][j] = min(dp[i-1][j] + A[i][j] , val + A[i-1][j] + A[i][j] )
        nxt_val = min(nxt_val,dp[i][j])
    val = nxt_val

print(min(dp[N-1][:]))
0