結果

問題 No.1607 Kth Maximum Card
ユーザー 👑 tute7627tute7627
提出日時 2021-04-09 18:35:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,248 ms / 3,500 ms
コード長 895 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 211,216 KB
実行使用メモリ 15,896 KB
最終ジャッジ日時 2023-09-20 12:28:12
合計ジャッジ時間 14,250 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1,248 ms
15,896 KB
testcase_09 AC 889 ms
14,004 KB
testcase_10 AC 1,156 ms
15,868 KB
testcase_11 AC 177 ms
5,972 KB
testcase_12 AC 859 ms
13,376 KB
testcase_13 AC 68 ms
5,016 KB
testcase_14 AC 78 ms
5,360 KB
testcase_15 AC 448 ms
12,296 KB
testcase_16 AC 69 ms
4,844 KB
testcase_17 AC 26 ms
4,380 KB
testcase_18 AC 250 ms
9,492 KB
testcase_19 AC 158 ms
7,128 KB
testcase_20 AC 267 ms
8,048 KB
testcase_21 AC 261 ms
8,436 KB
testcase_22 AC 595 ms
14,836 KB
testcase_23 AC 663 ms
14,908 KB
testcase_24 AC 173 ms
6,792 KB
testcase_25 AC 95 ms
5,332 KB
testcase_26 AC 115 ms
5,932 KB
testcase_27 AC 167 ms
7,016 KB
testcase_28 AC 131 ms
6,140 KB
testcase_29 AC 379 ms
9,892 KB
testcase_30 AC 966 ms
14,244 KB
testcase_31 AC 357 ms
9,428 KB
testcase_32 AC 152 ms
8,964 KB
testcase_33 AC 152 ms
8,744 KB
testcase_34 AC 151 ms
8,860 KB
testcase_35 AC 151 ms
8,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

struct edge{
  int to;
  int c;
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  
  vector<vector<edge>>g(n);
  for(int i = 0; i < m; i++){
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }

  using pi = pair<int, int>;
  int ok = 300000, ng = -1;
  while(ok - ng >= 2){
    int mid = (ok + ng) / 2;
    priority_queue<pi, vector<pi>, greater<pi>>que;
    vector<int>dist(n, 1e9);
    dist[0] = 0;
    que.emplace(0, 0);
    while(!que.empty()){
      auto [d, v] = que.top();
      que.pop();
      if(dist[v] != d)continue;
      for(auto e:g[v]){
        int nd = d + (e.c > mid);
        if(dist[e.to] > nd){
          dist[e.to] = nd;
          que.emplace(nd, e.to);
        }
      }
    }

    if(dist[n - 1] < k)ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}
0