結果

問題 No.1 道のショートカット
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-08 21:18:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 6,608 KB
実行使用メモリ 6,660 KB
最終ジャッジ日時 2023-09-27 21:38:16
合計ジャッジ時間 2,399 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,144 KB
testcase_01 AC 10 ms
6,212 KB
testcase_02 AC 10 ms
6,152 KB
testcase_03 AC 10 ms
6,372 KB
testcase_04 AC 10 ms
6,312 KB
testcase_05 AC 11 ms
6,144 KB
testcase_06 AC 10 ms
6,284 KB
testcase_07 AC 10 ms
6,420 KB
testcase_08 AC 13 ms
6,372 KB
testcase_09 AC 12 ms
6,244 KB
testcase_10 AC 14 ms
6,380 KB
testcase_11 AC 13 ms
6,316 KB
testcase_12 AC 14 ms
6,660 KB
testcase_13 AC 14 ms
6,568 KB
testcase_14 AC 10 ms
6,292 KB
testcase_15 AC 10 ms
6,396 KB
testcase_16 AC 11 ms
6,280 KB
testcase_17 AC 10 ms
6,148 KB
testcase_18 AC 10 ms
6,212 KB
testcase_19 AC 11 ms
6,300 KB
testcase_20 AC 10 ms
6,184 KB
testcase_21 AC 10 ms
6,368 KB
testcase_22 AC 11 ms
6,396 KB
testcase_23 AC 16 ms
6,612 KB
testcase_24 AC 14 ms
6,480 KB
testcase_25 AC 11 ms
6,188 KB
testcase_26 AC 10 ms
6,196 KB
testcase_27 AC 14 ms
6,504 KB
testcase_28 AC 10 ms
6,400 KB
testcase_29 AC 13 ms
6,288 KB
testcase_30 AC 11 ms
6,196 KB
testcase_31 AC 13 ms
6,424 KB
testcase_32 AC 12 ms
6,248 KB
testcase_33 AC 11 ms
6,224 KB
testcase_34 AC 14 ms
6,444 KB
testcase_35 AC 13 ms
6,348 KB
testcase_36 AC 13 ms
6,256 KB
testcase_37 AC 12 ms
6,468 KB
testcase_38 AC 11 ms
6,172 KB
testcase_39 AC 11 ms
6,264 KB
testcase_40 AC 12 ms
6,276 KB
testcase_41 AC 10 ms
6,192 KB
testcase_42 AC 9 ms
6,376 KB
testcase_43 AC 10 ms
6,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from heapq import heappush, heappop
N = int(raw_input())
C = int(raw_input())
V = int(raw_input())
S = map(int, raw_input().split())
T = map(int, raw_input().split())
Y = map(int, raw_input().split())
M = map(int, raw_input().split())

adjList = [ [] for i in range(N) ]
for (s,t,y,m) in zip(S,T,Y,M):
   adjList[s-1].append((t-1,y,m))

minDist = [7500000 for i in range(N)]
heap = []
heappush(heap, (0,0,C) )
while len(heap) != 0:
   (time, pos, cost) = heappop(heap)
   if pos == N-1:
      print time
      exit()
   for (t,y,m) in adjList[pos]:
      if cost - y >= 0:
         heappush( heap, (time+m, t, cost-y) )

print -1


0