結果

問題 No.1449 新プロランド
ユーザー SSRSSSRS
提出日時 2021-03-31 14:48:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,615 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 1,765 ms
コンパイル使用メモリ 180,540 KB
実行使用メモリ 21,008 KB
最終ジャッジ日時 2023-08-25 16:46:20
合計ジャッジ時間 15,856 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 14 ms
4,380 KB
testcase_02 AC 186 ms
4,492 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 1,615 ms
20,016 KB
testcase_06 AC 837 ms
14,140 KB
testcase_07 AC 357 ms
14,720 KB
testcase_08 AC 893 ms
20,984 KB
testcase_09 AC 913 ms
6,848 KB
testcase_10 AC 327 ms
18,188 KB
testcase_11 AC 63 ms
19,924 KB
testcase_12 AC 892 ms
17,848 KB
testcase_13 AC 592 ms
8,956 KB
testcase_14 AC 85 ms
20,672 KB
testcase_15 AC 967 ms
15,812 KB
testcase_16 AC 727 ms
10,324 KB
testcase_17 AC 709 ms
14,000 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 12 ms
16,236 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 188 ms
14,664 KB
testcase_22 AC 68 ms
4,760 KB
testcase_23 AC 277 ms
19,452 KB
testcase_24 AC 459 ms
6,336 KB
testcase_25 AC 132 ms
5,732 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 1,514 ms
21,008 KB
testcase_28 AC 1,164 ms
9,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int MAX = 50000;
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>(MAX + 1, INF));
  priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;
  pq.push(make_tuple(T[0], 0, T[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;
      for (auto P : E[v]){
        int w = P.second;
        if (c + T[w] <= MAX){
          if (d[w][c + T[w]] == INF){
            pq.push(make_tuple(dd + P.first / c + T[w], w, c + T[w]));
          }
        }
      }
    }
  }
  int ans = INF;
  for (int i = 0; i <= MAX; i++){
    ans = min(ans, d[N - 1][i]);
  }
  cout << ans << endl;
}
0