結果

問題 No.3013 ハチマキ買い星人
ユーザー ねしん
提出日時 2025-01-25 13:26:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,047 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,508 KB
実行使用メモリ 144,020 KB
最終ジャッジ日時 2025-01-25 22:47:34
合計ジャッジ時間 23,247 ms
ジャッジサーバーID
(参考情報)
judge7 / judge11
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import heapq
N,M,P,Y=list(map(int,input().split()))
dist=[10**18]*N
path=defaultdict(list)
for i in range(M):
	u,v,c=list(map(int,input().split()))
	u-=1
	v-=1
	path[u].append((v,c))
	path[v].append((u,c))
dist[0]=0
c=set()
Q=[]
heapq.heapify(Q)
heapq.heappush(Q,(0,0))
while len(Q)>0:
	d,p=heapq.heappop(Q)
	if p in c:
		continue
	c.add(p)
	for j,v in path[p]:
		if d+v<dist[j]:
			heapq.heappush(Q,(d+v,j))
			dist[j]=d+v
ans=0
for i in range(P):
	d,e=list(map(int,input().split()))
	d-=1
	ans=max(ans,(Y-dist[d])//e)
print(ans)
0