結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
![]() |
提出日時 | 2025-01-26 00:40:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 1,219 bytes |
コンパイル時間 | 5,866 ms |
コンパイル使用メモリ | 284,156 KB |
実行使用メモリ | 20,824 KB |
最終ジャッジ日時 | 2025-01-26 00:40:16 |
合計ジャッジ時間 | 9,588 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; template<class T>using V=vector<T>; template<class T>using VV=V<V<T>>;//B(n,V<int>(n)) const ll INF=1LL<<60; struct Edge{ int to; ll w; Edge(int to,ll w):to(to),w(w){} }; using Graph=VV<Edge>; using pli=pair<ll,int>; template<class T> bool chmin(T& a,T b){ return ((a>b)?(a=b,true):(false)); } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n,m,p,y; cin>>n>>m>>p>>y; Graph G(n); rep(i,m){ int a,b,w; cin>>a>>b>>w; a--,b--; G[a].push_back(Edge(b,w)); G[b].push_back(Edge(a,w)); } V<ll> dist(n,INF); int s=0; dist[s]=0; priority_queue<pli,vector<pli>,greater<pli>> que; que.push({dist[s],s}); while(!que.empty()){ int v=que.top().second; ll d=que.top().first; que.pop(); if(d>dist[v]) continue; for(auto e:G[v]){ if(chmin(dist[e.to],dist[v]+e.w)){ que.push({dist[e.to],e.to}); } } } ll ans=0; rep(i,p){ ll d,e; cin>>d>>e; d--; ll t=y-dist[d]; if(t<=0) continue; ans=max(ans,t/e); } cout<<ans<<endl; return 0; }