結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-12 15:01:24 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 263 ms / 2,000 ms |
| + 95µs | |
| コード長 | 1,055 bytes |
| 記録 | |
| コンパイル時間 | 2,047 ms |
| コンパイル使用メモリ | 205,156 KB |
| 実行使用メモリ | 20,404 KB |
| 最終ジャッジ日時 | 2026-09-12 15:01:33 |
| 合計ジャッジ時間 | 6,422 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
ll get(ll t, ll a, ll b, ll c){
if(t==0) t++;
ll k=(t+a-1)/a, ans=k*a;
if(k%b==0) ans+=c;
return min(ans, (k+1)*a);
}
int main(void){
int n, m; cin >> n >> m;
vector<vector<P>> to(n);
for(int i=0; i<m; i++){
int u, v; ll w; cin >> u >> v >> w; u--, v--;
to[u].emplace_back(v, w); swap(u, v);
to[u].emplace_back(v, w);
}
vector<ll> a(n), b(n), c(n);
for(auto&x:a) cin >> x;
for(auto&x:b) cin >> x;
for(auto&x:c) cin >> x;
vector<ll> dist(n, 1e18);
priority_queue<P, vector<P>, greater<P>> pri;
pri.emplace(0, 0);
dist[0]=0;
while(pri.size()){
auto [d, id]=pri.top(); pri.pop();
if(dist[id]!=d) continue;
for(auto [v, w]:to[id]){
ll nd=get(d, a[id], b[id], c[id])+w;
if(dist[v]>nd){
dist[v]=nd;
pri.emplace(nd, v);
}
}
}
//for(auto p:dist) cout << p << ' '; cout << endl;
cout << dist[n-1] << endl;
return 0;
}