結果
| 問題 |
No.1449 新プロランド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 15:27:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 967 bytes |
| コンパイル時間 | 789 ms |
| コンパイル使用メモリ | 81,908 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-24 01:54:14 |
| 合計ジャッジ時間 | 1,719 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >G[100];
int T[100];
int dist[100][1002];
main()
{
cin>>N>>M;
for(int i=0;i<M;i++)
{
int a,b,c;cin>>a>>b>>c;
a--,b--;
G[a].push_back(make_pair(b,c));
G[b].push_back(make_pair(a,c));
}
for(int i=0;i<N;i++)
{
cin>>T[i];
for(int j=0;j<=1001;j++)dist[i][j]=1e9;
}
dist[0][0]=0;
priority_queue<pair<int,pair<int,int> > >P;
P.push(make_pair(0,make_pair(0,0)));
while(!P.empty())
{
int u=P.top().second.first;
int t=P.top().second.second;
int cost=-P.top().first;
P.pop();
if(dist[u][t]<cost)continue;
int nt=t+T[u];
if(nt>=1001)nt=1001;
for(pair<int,int>e:G[u])
{
int v=e.first;
int nxt=cost+e.second/nt+T[u];
if(dist[v][nt]>nxt)
{
dist[v][nt]=nxt;
P.push(make_pair(-nxt,make_pair(v,nt)));
}
}
}
int ans=1e9;
for(int j=0;j<=1001;j++)ans=min(ans,dist[N-1][j]);
cout<<ans<<endl;
}