結果

問題 No.1449 新プロランド
ユーザー SSRSSSRS
提出日時 2021-03-31 14:17:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,118 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 181,972 KB
実行使用メモリ 41,316 KB
最終ジャッジ日時 2023-08-25 16:45:09
合計ジャッジ時間 5,683 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,760 KB
testcase_01 AC 19 ms
5,152 KB
testcase_02 AC 323 ms
5,628 KB
testcase_03 AC 7 ms
4,992 KB
testcase_04 AC 9 ms
4,984 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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>(100001, 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] <= 100000){
        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 <= 100000; i++){
    ans = min(ans, d[N - 1][i]);
  }
  cout << ans << endl;
}
0