結果

問題 No.1449 新プロランド
ユーザー SSRSSSRS
提出日時 2021-03-31 14:45:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,658 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 2,445 ms
コンパイル使用メモリ 181,876 KB
実行使用メモリ 20,784 KB
最終ジャッジ日時 2023-08-25 16:46:06
合計ジャッジ時間 16,862 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 11 ms
4,376 KB
testcase_02 AC 166 ms
4,404 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 1,658 ms
20,088 KB
testcase_06 AC 821 ms
14,180 KB
testcase_07 AC 354 ms
14,656 KB
testcase_08 AC 906 ms
20,764 KB
testcase_09 AC 890 ms
6,720 KB
testcase_10 AC 338 ms
18,216 KB
testcase_11 AC 62 ms
19,968 KB
testcase_12 AC 915 ms
18,112 KB
testcase_13 AC 601 ms
8,960 KB
testcase_14 AC 83 ms
20,760 KB
testcase_15 AC 968 ms
15,712 KB
testcase_16 AC 738 ms
10,264 KB
testcase_17 AC 705 ms
13,836 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 12 ms
16,240 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 199 ms
14,684 KB
testcase_22 AC 61 ms
4,628 KB
testcase_23 AC 275 ms
19,452 KB
testcase_24 AC 460 ms
6,148 KB
testcase_25 AC 135 ms
5,760 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 1,552 ms
20,784 KB
testcase_28 AC 1,128 ms
9,788 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(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] <= MAX){
        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 <= MAX; i++){
    ans = min(ans, d[N - 1][i]);
  }
  cout << ans << endl;
}
0