結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2016-08-22 21:42:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-08 04:29:47 |
合計ジャッジ時間 | 2,875 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 4 WA * 36 |
ソースコード
import heapq N,C,V = int(input()),int(input()),int(input()) S = [int(i) - 1 for i in input().split()] T = [int(i) - 1 for i in input().split()] Y = [int(i) for i in input().split()] M = [int(i) for i in input().split()] cost = [[-1 for j in range(N)]for i in range(N)] time = [[-1 for j in range(N)] for i in range(N)] for i in range(V): cost[S[i]][T[i]] = Y[i] for i in range(V): time[S[i]][T[i]] = M[i] def dijkstra(): q = [(0,C,0)] while len(q) > 0: d = heapq.heappop(q) if d[2] == N - 1 and d[1] >= 0: print(d[2]) return d[0] for i in range(N): if d[2] == i or cost[d[2]][i] == -1 or time[d[2]][i] == -1: continue heapq.heappush(q,(d[0] + time[d[2]][i],d[1] - cost[d[2]][i],i)) return -1 print(dijkstra())