結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-11 22:32:58 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 245 ms / 2,000 ms |
| + 578µs | |
| コード長 | 1,073 bytes |
| 記録 | |
| コンパイル時間 | 4,042 ms |
| コンパイル使用メモリ | 364,128 KB |
| 実行使用メモリ | 16,300 KB |
| 最終ジャッジ日時 | 2026-09-11 22:33:06 |
| 合計ジャッジ時間 | 7,463 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
#define rep(i,n) for(int i=0;i<(n);++i)
template<typename T>
void chmax(T& a,T b){if(a<b){a=b;};}
template<typename T>
void chmin(T& a,T b){if(a>b){a=b;};}
const int inf=1e9;
const ll linf=1e18;
int main(){
int n,m;cin>>n>>m;
vector<vector<pint>> graph(n);
rep(i,m){
int u,v,w;cin>>u>>v>>w;
u--,v--;
graph[u].emplace_back(v,w);
graph[v].emplace_back(u,w);
}
vector<ll> a(n),b(n),c(n);
rep(i,n)cin>>a[i];
rep(i,n)cin>>b[i];
rep(i,n)cin>>c[i];
vector<ll> dist(n,linf);
min_priority_queue<pair<ll,int>> pq;
pq.emplace(dist[0]=0,0);
while(pq.size()){
auto [d,v]=pq.top();pq.pop();
if(dist[v]<d)continue;
for(auto [nv,w]:graph[v]){
ll t=max(a[v],(d+a[v]-1)/a[v]*a[v]);
if(t/a[v]%b[v]==0)t=min(t+c[v],t+a[v]);
ll nd=t+w;
if(dist[nv]<=nd)continue;
pq.emplace(dist[nv]=nd,nv);
}
}
cout<<dist.back()<<endl;
}