結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2021-10-30 02:43:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 5,000 ms |
| コード長 | 611 bytes |
| コンパイル時間 | 288 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 67,784 KB |
| 最終ジャッジ日時 | 2024-10-07 13:18:39 |
| 合計ジャッジ時間 | 3,081 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
n = int(input())
c = int(input())
a = int(input())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
edge = [[] for i in range(n)]
for i in range(a):
s, t, y, m = S[i], T[i], Y[i], M[i]
s, t = s-1, t-1
edge[s].append((y, m, t))
INF = 10**18
import heapq
hq = [(0, 0, 0)]
heapq.heapify(hq)
while hq:
time, cost, v = heapq.heappop(hq)
if v == n-1:
print(time)
exit()
for y, m, u in edge[v]:
if cost+y <= c:
heapq.heappush(hq, (time+m, cost+y, u))
print(-1)
brthyyjp