結果
問題 | No.1449 新プロランド |
ユーザー |
|
提出日時 | 2024-04-29 16:53:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 1,084 bytes |
コンパイル時間 | 4,560 ms |
コンパイル使用メモリ | 259,912 KB |
最終ジャッジ日時 | 2025-02-21 09:39:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#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;}