結果

問題 No.2387 Yokan Factory
ユーザー 👑 tatyamtatyam
提出日時 2023-07-17 19:40:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 320 ms / 5,000 ms
コード長 1,341 bytes
コンパイル時間 3,812 ms
コンパイル使用メモリ 265,024 KB
実行使用メモリ 13,100 KB
最終ジャッジ日時 2023-10-18 00:35:22
合計ジャッジ時間 10,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 183 ms
13,100 KB
testcase_16 AC 140 ms
12,868 KB
testcase_17 AC 235 ms
12,892 KB
testcase_18 AC 239 ms
11,712 KB
testcase_19 AC 195 ms
9,456 KB
testcase_20 AC 164 ms
8,728 KB
testcase_21 AC 313 ms
11,092 KB
testcase_22 AC 146 ms
8,244 KB
testcase_23 AC 198 ms
9,416 KB
testcase_24 AC 75 ms
8,744 KB
testcase_25 AC 100 ms
6,768 KB
testcase_26 AC 215 ms
10,036 KB
testcase_27 AC 320 ms
11,040 KB
testcase_28 AC 3 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 2 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const i64 INF = LLONG_MAX / 4;
void chmin(i64& a, i64 b) { if(a > b) a = b; }

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    i64 N, M, X;
    cin >> N >> M >> X;
    vector g(N, vector<array<i64, 3>>{});
    
    vector<i64> width = {-1};
    while(M--) {
        i64 a, b, d, w;
        cin >> a >> b >> d >> w;
        a--; b--;
        g[a].push_back({b, d, w});
        g[b].push_back({a, d, w});
        
        width.push_back(w);
    }
    
    sort(width.begin(), width.end());
    
    auto check = [&](i64 i_) -> bool {
        const i64 W = width[i_];
        vector cost(N, INF);
        priority_queue q(greater<>{}, vector<pair<i64, i64>>{});
        auto push = [&](i64 i, i64 c) {
            if(cost[i] <= c) return;
            cost[i] = c;
            q.emplace(c, i);
        };
        push(0, 0);
        while(q.size()) {
            auto [c, i] = q.top();
            q.pop();
            if(cost[i] != c) continue;
            for(auto [j, d, w] : g[i]) if(w >= W) push(j, c + d);
        }
        return cost.back() <= X;
    };
    
    i64 ok = 0, ng = width.size();
    while(ng - ok > 1) {
        const i64 mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << width[ok] << endl;
}
0