結果

問題 No.2095 High Rise
ユーザー flygonflygon
提出日時 2022-10-07 22:01:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 86,992 KB
最終ジャッジ日時 2023-09-03 12:29:43
合計ジャッジ時間 4,992 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,464 KB
testcase_01 AC 62 ms
71,416 KB
testcase_02 AC 62 ms
71,140 KB
testcase_03 AC 63 ms
71,576 KB
testcase_04 AC 65 ms
71,420 KB
testcase_05 AC 60 ms
71,296 KB
testcase_06 AC 63 ms
71,412 KB
testcase_07 AC 63 ms
71,640 KB
testcase_08 AC 64 ms
71,348 KB
testcase_09 AC 62 ms
71,188 KB
testcase_10 AC 61 ms
71,416 KB
testcase_11 AC 60 ms
71,604 KB
testcase_12 AC 71 ms
76,908 KB
testcase_13 AC 70 ms
76,836 KB
testcase_14 AC 72 ms
76,568 KB
testcase_15 AC 73 ms
76,464 KB
testcase_16 AC 72 ms
76,348 KB
testcase_17 AC 91 ms
77,800 KB
testcase_18 AC 89 ms
77,700 KB
testcase_19 AC 75 ms
76,696 KB
testcase_20 AC 90 ms
77,432 KB
testcase_21 AC 114 ms
81,260 KB
testcase_22 AC 205 ms
86,940 KB
testcase_23 AC 207 ms
86,848 KB
testcase_24 AC 198 ms
86,992 KB
testcase_25 AC 206 ms
86,828 KB
testcase_26 AC 196 ms
86,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
INF = 10**18
if n == 1:print(0); exit()
dp = [[INF]*(m) for i in range(n)]
dp[-1] = a[-1][::1]
for i in range(n-1)[::-1]:
  mn = INF
  for j in range(m):
    dp[i][j] =  dp[i+1][j] + a[i][j]
    mn = min(mn,dp[i][j])
  for j in range(m):
    if dp[i][j] == mn: continue
    dp[i][j] = min(dp[i][j], mn + a[i][j])

print(min(dp[0]))
0