結果
| 問題 | No.1449 新プロランド | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-04-01 14:40:16 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 155 ms / 2,000 ms | 
| コード長 | 1,895 bytes | 
| コンパイル時間 | 1,731 ms | 
| コンパイル使用メモリ | 122,456 KB | 
| 実行使用メモリ | 10,240 KB | 
| 最終ジャッジ日時 | 2024-12-24 02:02:04 | 
| 合計ジャッジ時間 | 3,551 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
#include <iostream>
//#include<atcoder/all>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> 
#include <vector>
#include <algorithm>
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue>
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set>
#include <bitset> 
#include <cctype>
//using namespace atcoder;
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<pair<ll, ll>>>;
vector<bool> seen;
bool C = true;
vector<ll> dist;
int main() {
	ll N, M;
	cin >> N >> M;
	seen.assign(N, false);
	Graph G(N);
	rep(i, M) {
		ll 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));
	}
	vll T(N);
	rep(i, N)cin >> T[i];
	vector<vll> dist(N, vll(N * 105, 1e18));
	priority_queue<pair<ll,pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> Q;
	dist[0][T[0]] = T[0];
	Q.push(make_pair(T[0],make_pair(0, T[0])));
	while (!Q.empty()) {
		auto p = Q.top();
		seen[p.second.first] = true;
		Q.pop();
		for (auto k : G[p.second.first]) {
			//if (seen[k.first])continue;
			if (p.second.second + T[k.first] >= N * 101)continue;
			if (dist[k.first][p.second.second + T[k.first]] > dist[p.second.first][p.second.second] + k.second / p.second.second + T[k.first]) {
				dist[k.first][p.second.second + T[k.first]] = dist[p.second.first][p.second.second] + k.second / p.second.second + T[k.first];
				Q.push(make_pair(dist[k.first][p.second.second + T[k.first]] ,make_pair(k.first, p.second.second + T[k.first])));
			}
		}
	}
	ll an = 1e18;
	rep(t, N * 101) {
		an = min(an, dist[N - 1][t]);
	}
	cout << an << endl;
}
            
            
            
        