結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-02-08 21:18:18 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 644 bytes |
| 記録 | |
| コンパイル時間 | 134 ms |
| コンパイル使用メモリ | 77,744 KB |
| 最終ジャッジ日時 | 2025-12-03 13:35:20 |
|
ジャッジサーバーID (参考情報) |
judge4 / 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