結果

問題 No.1449 新プロランド
ユーザー karinohitokarinohito
提出日時 2021-04-01 14:40:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,895 bytes
コンパイル時間 1,410 ms
コンパイル使用メモリ 121,776 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2023-08-25 16:51:27
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 135 ms
9,568 KB
testcase_06 AC 46 ms
5,840 KB
testcase_07 AC 27 ms
5,840 KB
testcase_08 AC 89 ms
10,188 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 33 ms
7,736 KB
testcase_11 AC 12 ms
9,192 KB
testcase_12 AC 76 ms
8,236 KB
testcase_13 AC 14 ms
4,376 KB
testcase_14 AC 15 ms
9,692 KB
testcase_15 AC 65 ms
6,820 KB
testcase_16 AC 23 ms
4,388 KB
testcase_17 AC 40 ms
5,816 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 5 ms
6,812 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 16 ms
6,152 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 30 ms
8,508 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 135 ms
9,976 KB
testcase_28 AC 24 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	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;
}
0