結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-17 19:41:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,338 bytes |
コンパイル時間 | 3,181 ms |
コンパイル使用メモリ | 263,664 KB |
実行使用メモリ | 20,124 KB |
最終ジャッジ日時 | 2024-09-17 21:37:08 |
合計ジャッジ時間 | 10,088 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 TLE * 1 -- * 22 |
ソースコード
#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(less<>{}, 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;}