結果

問題 No.1449 新プロランド
ユーザー あかりきあかりき
提出日時 2021-04-12 23:44:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 96,948 KB
最終ジャッジ日時 2023-08-25 16:53:13
合計ジャッジ時間 8,632 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
76,308 KB
testcase_01 AC 161 ms
79,008 KB
testcase_02 AC 202 ms
80,752 KB
testcase_03 AC 120 ms
78,372 KB
testcase_04 AC 143 ms
78,664 KB
testcase_05 AC 417 ms
96,592 KB
testcase_06 AC 323 ms
89,224 KB
testcase_07 AC 243 ms
86,496 KB
testcase_08 AC 382 ms
93,572 KB
testcase_09 AC 316 ms
86,708 KB
testcase_10 AC 313 ms
89,828 KB
testcase_11 AC 228 ms
87,748 KB
testcase_12 AC 349 ms
91,764 KB
testcase_13 AC 302 ms
85,528 KB
testcase_14 AC 226 ms
87,744 KB
testcase_15 AC 315 ms
91,408 KB
testcase_16 AC 306 ms
87,228 KB
testcase_17 AC 279 ms
88,244 KB
testcase_18 AC 93 ms
76,672 KB
testcase_19 AC 114 ms
82,144 KB
testcase_20 AC 83 ms
75,196 KB
testcase_21 AC 258 ms
87,476 KB
testcase_22 AC 193 ms
79,960 KB
testcase_23 AC 299 ms
91,820 KB
testcase_24 AC 272 ms
84,568 KB
testcase_25 AC 95 ms
76,508 KB
testcase_26 AC 109 ms
78,396 KB
testcase_27 AC 459 ms
96,948 KB
testcase_28 AC 345 ms
89,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
t=list(map(int,input().split()))

import heapq
def dijkstra_heap(s,list,n):
  edge=list
  d=[10**18]*n
  used=[True]*n 
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while len(edgelist):
    minedge=heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,(e[0]+d[v],e[1]))
  return d

edge=[[] for i in range(n*1001)]
for i in range(m):
  for j in range(1001):
    if j+t[l[i][0]-1]>0:
      edge[j*n+(l[i][0]-1)].append((t[l[i][0]-1]+l[i][2]//(j+t[l[i][0]-1]),min(j+t[l[i][0]-1],1000)*n+l[i][1]-1))
    if j+t[l[i][1]-1]>0:
      edge[j*n+(l[i][1]-1)].append((t[l[i][1]-1]+l[i][2]//(j+t[l[i][1]-1]),min(j+t[l[i][1]-1],1000)*n+l[i][0]-1))

l=dijkstra_heap(0,edge,n*1001)
ans=[]
for i in range(1001):
  ans.append(l[i*n+n-1])
print(min(ans))
0