結果

問題 No.2095 High Rise
ユーザー flygonflygon
提出日時 2022-10-07 21:56:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 712 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 86,504 KB
実行使用メモリ 98,396 KB
最終ジャッジ日時 2023-09-03 01:43:11
合計ジャッジ時間 11,832 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,268 KB
testcase_01 AC 86 ms
71,172 KB
testcase_02 AC 81 ms
71,224 KB
testcase_03 AC 85 ms
71,172 KB
testcase_04 AC 86 ms
71,236 KB
testcase_05 AC 85 ms
71,272 KB
testcase_06 AC 86 ms
71,012 KB
testcase_07 AC 82 ms
71,276 KB
testcase_08 AC 78 ms
71,152 KB
testcase_09 AC 93 ms
70,780 KB
testcase_10 AC 85 ms
71,144 KB
testcase_11 AC 86 ms
71,176 KB
testcase_12 AC 141 ms
78,184 KB
testcase_13 AC 128 ms
78,156 KB
testcase_14 AC 143 ms
78,172 KB
testcase_15 AC 139 ms
78,448 KB
testcase_16 AC 120 ms
77,608 KB
testcase_17 AC 672 ms
84,064 KB
testcase_18 AC 389 ms
81,176 KB
testcase_19 AC 185 ms
78,748 KB
testcase_20 AC 1,124 ms
88,168 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
if n == 1: print(0); exit()
from heapq import heappop, heappush
INF = 10**15
dist = [[INF]*(m) for i in range(n)]*(n+1)
que = []
for i in range(m):
  heappush(que, (a[n-1][i],n-1, i))
  dist[n-1][i] = a[n-1][i]
while que:
  c, x,y = heappop(que)
  if x == 0:
    print(c)
    exit()
  if c > dist[x][y]: continue
  for nxt in range(m):
    anxt = a[x][nxt]
    if dist[x][y] + anxt < dist[x][nxt]:
      dist[x][nxt] = dist[x][y] + anxt
      heappush(que,(dist[x][nxt],x,nxt))
  if x != 0:
    if dist[x][y] + a[x-1][y] < dist[x-1][y]:
      dist[x-1][y] = dist[x][y] + a[x-1][y]
      heappush(que, (dist[x-1][y], x-1, y))

0