結果

問題 No.2387 Yokan Factory
ユーザー にしろにしろ
提出日時 2024-04-26 03:41:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 477 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 6,875 ms
コンパイル使用メモリ 338,328 KB
実行使用メモリ 13,152 KB
最終ジャッジ日時 2024-04-26 03:41:24
合計ジャッジ時間 12,793 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,948 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 259 ms
13,152 KB
testcase_16 AC 157 ms
12,136 KB
testcase_17 AC 399 ms
12,100 KB
testcase_18 AC 247 ms
11,148 KB
testcase_19 AC 295 ms
9,052 KB
testcase_20 AC 246 ms
8,320 KB
testcase_21 AC 477 ms
10,704 KB
testcase_22 AC 227 ms
8,152 KB
testcase_23 AC 362 ms
8,996 KB
testcase_24 AC 172 ms
8,248 KB
testcase_25 AC 208 ms
6,940 KB
testcase_26 AC 366 ms
9,552 KB
testcase_27 AC 455 ms
10,388 KB
testcase_28 AC 4 ms
6,944 KB
testcase_29 AC 5 ms
6,940 KB
testcase_30 AC 5 ms
6,940 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 4 ms
6,940 KB
testcase_35 AC 4 ms
6,944 KB
testcase_36 AC 3 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 m=(ok+ng)/2;
        vector<ll> total_cost(n,inf);
        total_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(total_cost[now]<cost) continue;
            for(auto[next,a,b]:g[now]){
                if(m>b) continue;
                if(total_cost[next]<=total_cost[now]+a) continue;
                total_cost[next]=total_cost[now]+a;
                q.push({total_cost[next],next});
            }
        }

        if(total_cost[n-1]<=x) ok=m;
        else ng=m;

    }

    if(ok==0) cout << -1;
    else cout << ok;
    
}
0