結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-02-01 00:23:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 739 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 82,732 KB |
実行使用メモリ | 139,504 KB |
最終ジャッジ日時 | 2025-02-01 00:23:35 |
合計ジャッジ時間 | 30,561 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 WA * 18 |
ソースコード
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:ans=max(ans,(Y-dist[d-1])//e)print(ans)