結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-01 14:56:43 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WA
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 810 bytes |
| 記録 | |
| コンパイル時間 | 64 ms |
| コンパイル使用メモリ | 82,404 KB |
| 実行使用メモリ | 77,880 KB |
| 最終ジャッジ日時 | 2026-10-11 16:49:14 |
| 合計ジャッジ時間 | 3,226 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 WA * 1 |
ソースコード
from heapq import heappush,heappop
n=int(input())
c=int(input())
v=int(input())
ss=list(map(int,input().split()))
tt=list(map(int,input().split()))
yy=list(map(int,input().split()))
mm=list(map(int,input().split()))
g=[[] for _ in range(n)]
for s,t,y,m in zip(ss,tt,yy,mm):
s-=1
t-=1
g[s].append([t,y,m])
inf=float('inf')
dp=[[inf]*(c+1) for _ in range(n)]
# dp[i][c]:残金cの状態で街iに到達する最小時間
q=[[0,0,c]]# 経過時間、街idx、残金
while q:
tm,ct,mn=heappop(q)
if dp[ct][mn]<tm:continue
for nct,dmn,dtm in g[ct]:
if mn-dmn<0:continue
if dp[nct][dmn]>tm+dtm:
dp[nct][dmn]=tm+dtm
heappush(q,[tm+dtm,nct,mn-dmn])
ans=inf
for mn in range(c+1):
ans=min(ans,dp[-1][mn])
if ans!=inf:
print(ans)
else:
print(-1)