結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-01-29 10:17:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,178 ms / 2,000 ms |
コード長 | 825 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 124,344 KB |
最終ジャッジ日時 | 2025-01-29 10:18:11 |
合計ジャッジ時間 | 29,059 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
import heapq def dijkstra(s): hq=[(0,s,0)] ans=[] heapq.heapify(hq) # リストを優先度付きキューに変換 cost=[float('inf')]*N # 行ったことのないところはinf cost[s]=0 # 開始地点は0 while hq: c,v,pre=heapq.heappop(hq) if c>cost[v]: # コストが現在のコストよりも高ければスルー v:now u:nex continue for d, u in E[v]: tmp=d+cost[v] if tmp<cost[u]: cost[u]=tmp heapq.heappush(hq,(tmp,u,v)) return cost N,M,P,Y=map(int,input().split()) E=[[] for _ in range(N)] for i in range(M): a,b,t=map(int,input().split()) a-=1 b-=1 E[a].append((t,b)) E[b].append((t,a)) A=dijkstra(0) ans=0 for i in range(P): d,e=map(int,input().split()) c=max(0,Y-A[d-1])//e ans=max(ans,c) print(ans)