結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
UT0911
|
| 提出日時 | 2026-07-21 20:49:00 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,037 bytes |
| 記録 | |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 102,528 KB |
| 実行使用メモリ | 17,664 KB |
| 最終ジャッジ日時 | 2026-09-11 20:50:43 |
| 合計ジャッジ時間 | 5,345 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 28 RE * 11 |
ソースコード
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
using ll = long long;
const ll MAXLL=8e18;
int main(){
int N,M;
cin >> N >> M;
vector<vector<pair<int,ll>>> edge(N+1);
for(int i=0;i<M;i++){
int U,V;
ll W;
cin >> U >> V >> W;
edge[U].push_back({V,W});
edge[V].push_back({U,W});
}
vector<ll> A(N+1,0);
for(int i=1;i<=N;i++){
cin >> A[i];
}
vector<ll> visited(N+1,MAXLL);
priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> q;
q.push({0LL,1});
while(!q.empty()){
auto [c,now]=q.top();
q.pop();
if(visited[now]>c){
visited[now]=c;
for(int i=0;i<edge[now].size();i++){
int next=edge[now][i].first;
ll t=((c+A[next]-1)/A[next])*A[next];
if(visited[next]>t+edge[now][next].second){
q.push({t+edge[now][next].second,next});
}
}
}
}
if(visited[N]==MAXLL){
cout << -1 << "\n";
}else{
cout << visited[N] << "\n";
}
return 0;
}
UT0911