結果

問題 No.2387 Yokan Factory
ユーザー 👑 tatyamtatyam
提出日時 2023-07-17 19:42:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,311 bytes
コンパイル時間 3,533 ms
コンパイル使用メモリ 263,540 KB
実行使用メモリ 17,176 KB
最終ジャッジ日時 2023-10-18 00:35:57
合計ジャッジ時間 10,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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);
        queue<pair<i64, i64>> q;
        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.front();
            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