結果
| 問題 | No.1449 新プロランド |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 15:57:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,371 bytes |
| 記録 | |
| コンパイル時間 | 4,693 ms |
| コンパイル使用メモリ | 202,628 KB |
| 最終ジャッジ日時 | 2025-01-20 02:00:53 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
using ll = long long;
using P = pair<ll, ll>;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll n, m; cin >> n >> m;
vector<ll> a(m), b(m), c(m);
rep(i, m) {
cin >> a[i] >> b[i] >> c[i];
a[i]--, b[i]--;
}
vector<ll> t(n);
rep(i, n) cin >> t[i];
vector<vector<P>> g(n);
rep(i, m) {
g[a[i]].push_back({b[i], c[i]});
g[b[i]].push_back({a[i], c[i]});
}
const ll INF = 1e9;
vector<ll> dist(n * (ll)1001, INF);
priority_queue<P, vector<P>, greater<P>> que;
dist[0 * (ll)1001 + t[0]] = t[0];
que.push({t[0], t[0]});
while (!que.empty()) {
P now = que.top(); que.pop();
ll nv = now.second, nc = now.first;
if(nc > dist[nv]) continue;
for (auto elem : g[nv / (ll)1001]) {
ll nnv = elem.first * (ll)1001 + min((ll)1000, nv % (ll)1001 + t[elem.first]);
ll nnc = nc + (elem.second + nv % (ll)1001 - 1) / (nv % (ll)1001) + t[elem.first];
if (nnc < dist[nnv]) {
dist[nnv] = nnc;
que.push({nnc, nnv});
}
}
}
ll ans = INF;
rep(i, (ll)1001) {
ans = min(ans, dist[(n - 1) * (ll)1001 + i]);
}
cout << ans << endl;
return 0;
}