結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-11 20:38:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 5,000 ms |
| コード長 | 566 bytes |
| コンパイル時間 | 347 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 65,792 KB |
| 最終ジャッジ日時 | 2024-11-23 17:24:05 |
| 合計ジャッジ時間 | 4,207 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
import heapq
N = int(input())
C = int(input())
V = 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()))
G=[[] for _ in range(N)]
for i in range(V):
G[S[i]-1].append((M[i],Y[i],T[i]-1))
hq=[(0,0,0,[False]*N)]
heapq.heapify(hq)
while(hq):
t,c,v,A=heapq.heappop(hq)
vis=A.copy()
vis[v]=True
if v==N-1:
print(t)
exit()
for m,y,u in G[v]:
if c+y<=C and vis[u]==0:
heapq.heappush(hq,(t+m,c+y,u,vis))
print(-1)