結果

問題 No.1449 新プロランド
ユーザー yansi819yansi819
提出日時 2024-04-29 16:53:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 4,916 ms
コンパイル使用メモリ 271,716 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 16:53:41
合計ジャッジ時間 5,135 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

struct edge {
  int to, cost;
};

int main() {
  int N, M; cin >> N >> M;
  vector<vector<edge>> g(N);
  for (int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  vector<int> t(N);
  for (int i = 0; i < N; i++) cin >> t[i];
  vector<vector<ll>> dist(N, vector<ll>(1010, 1e18));
  dist[0][0] = 0;
  priority_queue<array<ll, 3>, vector<array<ll, 3>>, greater<array<ll, 3>>> pq;
  pq.push({0, 0, 0});
  while (!pq.empty()) {
    auto [c, v, p] = pq.top(); pq.pop();
    if (dist[v][p] < c) continue;
    c += t[v]; p = min(p + t[v], 1001LL);
    for (auto e: g[v]) {
      if (dist[e.to][p] > c + e.cost / p) {
        dist[e.to][p] = c + e.cost / p;
        pq.push({c + e.cost /p, e.to, p});
      }
    }
  }
  ll ans = 1e18;
  for (int i = 0; i <= 1001; i++) ans = min(ans, dist[N - 1][i]);
  cout << ans << endl;
  return 0;
}
0