結果

問題 No.1449 新プロランド
ユーザー SSRSSSRS
提出日時 2021-03-31 14:57:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,109 bytes
コンパイル時間 2,817 ms
コンパイル使用メモリ 180,728 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 16:46:40
合計ジャッジ時間 3,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 6 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 28 ms
4,380 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 17 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 15 ms
4,376 KB
testcase_13 AC 15 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 18 ms
4,380 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 15 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 13 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 30 ms
4,380 KB
testcase_28 AC 28 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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