結果

問題 No.2387 Yokan Factory
ユーザー Nzt3
提出日時 2023-07-22 20:14:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 395 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 204,612 KB
最終ジャッジ日時 2025-02-15 18:11:14
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  ll X;
  cin>>N>>M>>X;
  vector<vector<array<ll,3>>>G(N);
  for(int i=0;i<M;i++){
    ll u,v;
    ll A,B;
    cin>>u>>v>>A>>B;
    --u,--v;
    G[u].push_back({v,A,B});
    G[v].push_back({u,A,B});
  }
  ll ans=-1,ng=1e9+1;
  while(ng-ans>1){
    int yokan=(ans+ng)/2;
    vector<ll>dist(N,X+1);
    dist[0]=0;
    priority_queue<array<ll,2>,vector<array<ll,2>>,greater<array<ll,2>>>pq;
    pq.push({0,0});
    while(pq.size()){
      ll d=pq.top()[0],v=pq.top()[1];
      pq.pop();
      if(dist[v]<d)continue;
      for(auto i:G[v]){
        if(i[2]>=yokan&&dist[i[0]]>d+i[1]){
          dist[i[0]]=d+i[1];
          pq.push({dist[i[0]],i[0]});
        }
      }
    }
    if(dist[N-1]<=X){
      ans=yokan;
    }else{
      ng=yokan;
    }
  }
  cout<<ans<<'\n';
}
0