結果

問題 No.2387 Yokan Factory
ユーザー RubikunRubikun
提出日時 2023-07-21 21:25:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 422 ms / 5,000 ms
コード長 1,532 bytes
コンパイル時間 4,636 ms
コンパイル使用メモリ 212,604 KB
実行使用メモリ 17,416 KB
最終ジャッジ日時 2023-10-21 21:13:42
合計ジャッジ時間 7,273 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,284 KB
testcase_01 AC 5 ms
12,284 KB
testcase_02 AC 5 ms
12,332 KB
testcase_03 AC 5 ms
12,284 KB
testcase_04 AC 5 ms
12,284 KB
testcase_05 AC 5 ms
12,332 KB
testcase_06 AC 6 ms
12,284 KB
testcase_07 AC 6 ms
12,284 KB
testcase_08 AC 5 ms
12,284 KB
testcase_09 AC 5 ms
12,284 KB
testcase_10 AC 5 ms
12,332 KB
testcase_11 AC 5 ms
12,284 KB
testcase_12 AC 5 ms
12,284 KB
testcase_13 AC 5 ms
12,332 KB
testcase_14 AC 5 ms
12,284 KB
testcase_15 AC 187 ms
17,416 KB
testcase_16 AC 99 ms
16,452 KB
testcase_17 AC 278 ms
16,852 KB
testcase_18 AC 365 ms
16,136 KB
testcase_19 AC 240 ms
15,096 KB
testcase_20 AC 194 ms
14,928 KB
testcase_21 AC 422 ms
15,960 KB
testcase_22 AC 181 ms
14,728 KB
testcase_23 AC 267 ms
15,060 KB
testcase_24 AC 97 ms
14,772 KB
testcase_25 AC 153 ms
14,032 KB
testcase_26 AC 369 ms
15,424 KB
testcase_27 AC 414 ms
15,840 KB
testcase_28 AC 6 ms
12,400 KB
testcase_29 AC 8 ms
12,436 KB
testcase_30 AC 7 ms
12,420 KB
testcase_31 AC 6 ms
12,388 KB
testcase_32 AC 5 ms
12,364 KB
testcase_33 AC 6 ms
12,364 KB
testcase_34 AC 7 ms
12,432 KB
testcase_35 AC 6 ms
12,412 KB
testcase_36 AC 6 ms
12,364 KB
testcase_37 AC 5 ms
12,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005;
const ll INF=1LL<<60;

vector<pair<int,pair<int,int>>> G[MAX];
ll dis[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,M,X;cin>>N>>M>>X;
    for(int i=0;i<M;i++){
        int a,b,c,d;cin>>a>>b>>c>>d;a--;b--;
        G[a].push_back(mp(b,mp(c,d)));
        G[b].push_back(mp(a,mp(c,d)));
    }
    ll left=0,right=2e9;
    while(right-left>1){
        ll mid=(left+right)/2;
        for(int i=0;i<N;i++) dis[i]=INF;
        dis[0]=0;
        
        priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
        PQ.push(mp(0,0));
        
        while(!PQ.empty()){
            auto [d,u]=PQ.top();PQ.pop();
            if(dis[u]<d) continue;
            for(auto to:G[u]){
                auto t=to.fi;
                auto [a,b]=to.se;
                if(b<mid) continue;
                if(chmin(dis[t],dis[u]+a)) PQ.push(mp(dis[t],t));
            }
        }
        
        if(dis[N-1]<=X) left=mid;
        else right=mid;
    }
    
    if(left==0) left=-1;
    cout<<left<<endl;
}
0