結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-02-08 21:18:18 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 5,000 ms |
| コード長 | 644 bytes |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 6,784 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-07-20 16:08:40 |
| 合計ジャッジ時間 | 2,357 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
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
yaoshimax