結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 14:40:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 974 ms / 2,000 ms |
| コード長 | 783 bytes |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 82,852 KB |
| 実行使用メモリ | 121,144 KB |
| 最終ジャッジ日時 | 2025-01-25 23:25:09 |
| 合計ジャッジ時間 | 21,372 ms |
|
ジャッジサーバーID (参考情報) |
judge8 / judge9 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
from heapq import *
n,m,p,y=map(int,input().split())
#???i????????????????????max
connect=[[] for _ in range(n+1)]
for i in range(m):
a,b,c=map(int,input().split())
connect[a].append((b,c))
connect[b].append((a,c))
store=[]
for i in range(p):
a,b=map(int,input().split())
store.append((a,b))
decide=[False]*(n+1)
que=[]
heappush(que,(-y,1))
inf=10**18
dist=[-inf]*(n+1)
dist[1]=y
while que:
cost,now=heappop(que)
cost*=-1
if dist[now]!=cost:
continue
decide[now]=True
for to,weight in connect[now]:
if not decide[to]:
if cost-weight>dist[to]:
dist[to]=cost-weight
heappush(que,(-(cost-weight),to))
ans=0
for i,j in store:
if dist[i]>0:
ans=max(ans,dist[i]//j)
print(ans)