結果

問題 No.1449 新プロランド
ユーザー karinohito
提出日時 2021-04-01 14:34:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,629 bytes
コンパイル時間 1,235 ms
コンパイル使用メモリ 114,420 KB
実行使用メモリ 76,644 KB
最終ジャッジ日時 2024-12-24 02:02:21
合計ジャッジ時間 12,848 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	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, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> Q;
	dist[0][T[0]] = T[0];
	Q.push(make_pair(0, T[0]));
	while (!Q.empty()) {
		auto p = Q.top();
		Q.pop();

		for (auto k : G[p.first]) {
			if (p.second + T[k.first] >= N * 101)continue;
			if (dist[k.first][p.second + T[k.first]] > dist[p.first][p.second] + k.second / p.second + T[k.first]) {
				dist[k.first][p.second + T[k.first]] = dist[p.first][p.second] + k.second / p.second + T[k.first];
				Q.push(make_pair(k.first, p.second + T[k.first]));
			}
		}
	}
	ll an = 1e18;
	rep(t, N * 101) {
		an = min(an, dist[N - 1][t]);
	}
	cout << an << endl;
}
0