結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
|
提出日時 | 2025-01-25 15:25:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 442 ms / 2,000 ms |
コード長 | 1,620 bytes |
コンパイル時間 | 6,035 ms |
コンパイル使用メモリ | 333,752 KB |
実行使用メモリ | 20,932 KB |
最終ジャッジ日時 | 2025-01-25 23:46:14 |
合計ジャッジ時間 | 17,801 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using mint = atcoder::static_modint<998244353>;// using mint = atcoder::static_modint<1000000007>;using namespace std;using namespace atcoder;using ld = long double;using ll = long long;#define mp(a,b) make_pair(a,b)#define rep(i,s,n) for(int i=s; i<n; i++)const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};struct dijkstra{public:dijkstra():_n(0){}dijkstra(int n):_n(n),G(n){}void add_edge(int from,int to,ll d){G[from].push_back({to,d});}vector<ll> start_from(int start){vector<ll> dist(_n,-1);priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> Q;Q.push({0,start});dist[start]=0;while(!Q.empty()){auto p=Q.top();Q.pop();int now=p.second;ll d=p.first;if(d!=dist[now])continue;for(auto e:G[now]){int to=e.first;ll w=e.second;if(dist[to]==-1 || w+d<dist[to])Q.push(mp(w+d,to)),dist[to]=w+d;}}return dist;}private:int _n;vector<vector<pair<int,ll>>> G;};int main(){ll n,m,p,y;cin >> n >> m >> p >> y;dijkstra G(n);rep(i,0,m){int a,b;cin >> a >> b;ll c;cin >> c;a--,b--;G.add_edge(a,b,c);swap(a,b);G.add_edge(a,b,c);}auto dist=G.start_from(0);ll ans=0;rep(i,0,p){ll d,e;cin >> d >> e;d--;if(dist[d]!=-1)ans=max(ans,max(0LL,y-dist[d])/e);}cout << ans;}