結果
| 問題 |
No.1449 新プロランド
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-03-31 23:00:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,666 bytes |
| コンパイル時間 | 3,343 ms |
| コンパイル使用メモリ | 187,128 KB |
| 最終ジャッジ日時 | 2025-01-20 04:28:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 1 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
int n, m;
cin>>n>>m;
int t[101];
vector<P> g[101];
for(int i=0; i<m; i++){
int a, b, c;
cin>>a>>b>>c; a--; b--;
g[a].push_back({b, c});
g[b].push_back({a, c});
}
for(int i=0; i<n; i++) cin>>t[i];
int dp[101][1010];
const int INF=1e9+7;
for(int i=0; i<n; i++){
fill(dp[i], dp[i]+1001, INF);
}
dp[0][0]=0;
using Pi=pair<int, P>;
priority_queue<Pi, vector<Pi>, greater<Pi>> que;
que.push({0, {0, 0}});
while(!que.empty()){
auto p=que.top();
que.pop();
int x=p.second.first, s=p.second.second;
if(dp[x][s]<p.first) continue;
int s1=min(1000, s+t[x]);
for(auto q:g[x]){
int y=q.first;
int c=q.second;
if(dp[y][s1]>dp[x][s]+c/s1+t[x]){
dp[y][s1]=dp[x][s]+c/s1+t[x];
que.push({dp[y][s1], {y, s1}});
}
}
}
int ans=INF;
for(int i=0; i<=1000; i++) ans=min(ans, dp[n-1][i]);
cout<<ans<<endl;
return 0;
}
chocorusk