結果

問題 No.2387 Yokan Factory
ユーザー Today03Today03
提出日時 2023-07-21 21:40:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 431 ms / 5,000 ms
コード長 1,025 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 216,012 KB
実行使用メモリ 12,308 KB
最終ジャッジ日時 2023-10-21 21:36:41
合計ジャッジ時間 7,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 248 ms
12,308 KB
testcase_16 AC 172 ms
11,808 KB
testcase_17 AC 358 ms
12,096 KB
testcase_18 AC 303 ms
10,996 KB
testcase_19 AC 264 ms
8,992 KB
testcase_20 AC 235 ms
8,416 KB
testcase_21 AC 431 ms
10,524 KB
testcase_22 AC 223 ms
7,912 KB
testcase_23 AC 284 ms
8,952 KB
testcase_24 AC 145 ms
8,336 KB
testcase_25 AC 175 ms
6,564 KB
testcase_26 AC 339 ms
9,644 KB
testcase_27 AC 392 ms
10,356 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n,m;
  long long x;
  cin>>n>>m>>x;
  vector<vector<tuple<int,long long,long long>>> g(n);
  for (int i=0;i<m;i++) {
    int u,v;
    long long a,b;
    cin>>u>>v>>a>>b;
    u--;
    v--;
    g[u].push_back({v,a,b});
    g[v].push_back({u,a,b});
  }
  long long l=-1,r=1e10;
  while (r-l>1) {
    long long mid=(l+r)/2;
    vector<long long> dst(n,LLONG_MAX);
    dst[0]=0;
    priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>>pq;
    pq.push({0,0});
    while (pq.size()) {
      auto [tmp,now]=pq.top();
      pq.pop();
      if (tmp>dst[now]) {
        continue;
      }
      for (auto [nxt,ngs,hb]:g[now]) {
        if (hb<mid) {
          continue;
        }
        if (dst[now]+ngs>dst[nxt]) {
          continue;
        }
        dst[nxt]=dst[now]+ngs;
        pq.push({dst[nxt],nxt});
      }
    }
    if (dst.back()<=x) {
      l=mid;
    }
    else {
      r=mid;
    }
  }
  cout<<(l<=0?-1:l)<<endl;
}
0