結果

問題 No.1449 新プロランド
ユーザー SSRSSSRS
提出日時 2021-03-31 14:18:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 651 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 2,501 ms
コンパイル使用メモリ 180,712 KB
実行使用メモリ 10,564 KB
最終ジャッジ日時 2023-08-25 16:45:19
合計ジャッジ時間 8,017 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 67 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 651 ms
10,024 KB
testcase_06 AC 325 ms
7,976 KB
testcase_07 AC 141 ms
7,892 KB
testcase_08 AC 360 ms
10,564 KB
testcase_09 AC 354 ms
4,948 KB
testcase_10 AC 133 ms
9,092 KB
testcase_11 AC 25 ms
9,704 KB
testcase_12 AC 359 ms
9,396 KB
testcase_13 AC 238 ms
5,784 KB
testcase_14 AC 34 ms
10,168 KB
testcase_15 AC 379 ms
8,800 KB
testcase_16 AC 291 ms
6,388 KB
testcase_17 AC 278 ms
7,328 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 6 ms
8,424 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 79 ms
7,788 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 108 ms
9,904 KB
testcase_24 AC 184 ms
4,624 KB
testcase_25 AC 52 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 616 ms
10,408 KB
testcase_28 AC 450 ms
5,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < M; i++){
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    E[A].push_back(make_pair(C, B));
    E[B].push_back(make_pair(C, A));
  }
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    cin >> T[i];
  }
  vector<vector<int>> d(N, vector<int>(20001, INF));
  priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;
  pq.push(make_tuple(0, 0, 0));
  while (!pq.empty()){
    int dd = get<0>(pq.top());
    int v = get<1>(pq.top());
    int c = get<2>(pq.top());
    pq.pop();
    if (d[v][c] == INF){
      d[v][c] = dd;
      if (c + T[v] <= 20000){
        for (auto P : E[v]){
          int w = P.second;
          if (d[w][c + T[v]] == INF){
            pq.push(make_tuple(dd + T[v] + P.first / (c + T[v]), w, c + T[v]));
          }
        }
      }
    }
  }
  int ans = INF;
  for (int i = 0; i <= 20000; i++){
    ans = min(ans, d[N - 1][i]);
  }
  cout << ans << endl;
}
0