結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2024-04-26 14:37:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 485 ms / 5,000 ms |
コード長 | 1,109 bytes |
コンパイル時間 | 6,028 ms |
コンパイル使用メモリ | 318,304 KB |
実行使用メモリ | 13,028 KB |
最終ジャッジ日時 | 2024-11-14 03:13:25 |
合計ジャッジ時間 | 11,715 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using ll = long long;const ll inf=9e18;int main(){ll n,m,x;cin >> n >> m >> x;vector<vector<array<ll,3>>> g(n);for(ll i=0;i<m;i++){ll u,v,a,b;cin >> u >> v >> a >> b;u--, v--;g[u].push_back({v,a,b});g[v].push_back({u,a,b});}ll ng=1e18+2,ok=-1;while(ng-ok>1){ll mid=(ok+ng)/2;vector<ll> min_cost(n,inf);min_cost[0]=0;priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;q.push({0,0});while(q.size()){auto[cost,now]=q.top();q.pop();if(min_cost[now]<cost) continue;for(auto[next,a,b]:g[now]){if(mid>b) continue;if(min_cost[next]<=min_cost[now]+a) continue;min_cost[next]=min_cost[now]+a;q.push({min_cost[next],next});}}if(min_cost[n-1]<=x) ok=mid;else ng=mid;}if(ok==0) cout << -1;else cout << ok;}