結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-02-01 00:49:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,364 ms / 2,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 139,432 KB |
最終ジャッジ日時 | 2025-02-01 00:50:16 |
合計ジャッジ時間 | 29,706 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
N,M,P,Y=map(int,input().split())edge = [[] for _ in range(N)]for i in range(M):a,b,c=map(int,input().split())edge[a-1].append((b-1,c))edge[b-1].append((a-1,c))l=[]for i in range(P):l.append(list(map(int,input().split())))import heapqdef dijkstra(s):hq=[]heapq.heappush(hq,[0,s])dist=[-1 for _ in range(N)]karidist=[10**20+1 for _ in range(N)]while len(hq)!=0:d,p=heapq.heappop(hq)if dist[p]==-1:dist[p]=dfor e,c in edge[p]:if karidist[e]>d+c:karidist[e]=d+cheapq.heappush(hq,[d+c,e])return distdist = dijkstra(0)ans=0for d,e in l:if dist[d-1]!=-1:ans=max(ans,(Y-dist[d-1])//e)print(ans)