結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-25 13:30:52 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 118 ms / 2,000 ms |
| + 179µs | |
| コード長 | 1,367 bytes |
| 記録 | |
| コンパイル時間 | 2,360 ms |
| コンパイル使用メモリ | 196,968 KB |
| 実行使用メモリ | 20,552 KB |
| 最終ジャッジ日時 | 2026-10-25 13:31:55 |
| 合計ジャッジ時間 | 6,028 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
using pli = pair<ll, int>;
struct line{
int to; ll t;
};
using Graph = vector<vector<line>>;
const ll INF = 1LL<<50;
Graph G(100010);
ll D[100010];
ll A[100010], B[100010], C[100010];
void Dijkstra(int src){
fill(&D[0], &D[0]+100010, INF);
D[src]=0LL;
priority_queue<pli, vector<pli>, greater<pli>> Q;
Q.push({0LL, src});
while(! Q.empty()){
auto [tm, cur] = Q.top();
Q.pop();
if (tm>D[cur]) continue;
ll k = (tm+A[cur]-1)/A[cur];
if(k==0LL) k=1LL;
ll add_time = 0LL;
if (k%B[cur]==0) add_time=min(A[cur], C[cur]);
for (auto [dst, t]: G[cur]){
if (k*A[cur]+t+add_time<D[dst]){
Q.push({D[dst]=k*A[cur]+t+add_time, dst});
}
}
}
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, M;
scanf("%d %d", &N, &M);
for (int i=0;i<M;i++){
int U, V; ll W; scanf("%d %d %lld", &U, &V, &W);
G[U].push_back({V, W});
G[V].push_back({U, W});
}
for (int i=1;i<=N;i++) scanf("%lld", &A[i]);
for (int i=1;i<=N;i++) scanf("%lld", &B[i]);
for (int i=1;i<=N;i++) scanf("%lld", &C[i]);
Dijkstra(1);
printf("%lld\n", D[N]);
return 0;
}