結果

問題 No.1449 新プロランド
ユーザー tomoT222tomoT222
提出日時 2021-03-31 14:18:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 3,329 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 102,416 KB
実行使用メモリ 34,160 KB
最終ジャッジ日時 2023-08-25 16:45:07
合計ジャッジ時間 3,376 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,484 KB
testcase_01 AC 32 ms
9,948 KB
testcase_02 AC 58 ms
20,752 KB
testcase_03 AC 43 ms
15,200 KB
testcase_04 AC 33 ms
11,516 KB
testcase_05 AC 75 ms
33,560 KB
testcase_06 AC 56 ms
20,684 KB
testcase_07 AC 50 ms
15,712 KB
testcase_08 AC 59 ms
20,680 KB
testcase_09 AC 80 ms
32,876 KB
testcase_10 AC 54 ms
20,856 KB
testcase_11 AC 35 ms
9,892 KB
testcase_12 AC 60 ms
21,756 KB
testcase_13 AC 81 ms
33,132 KB
testcase_14 AC 36 ms
9,896 KB
testcase_15 AC 55 ms
20,588 KB
testcase_16 AC 60 ms
21,252 KB
testcase_17 AC 56 ms
21,672 KB
testcase_18 AC 10 ms
8,464 KB
testcase_19 AC 4 ms
8,716 KB
testcase_20 AC 4 ms
8,492 KB
testcase_21 AC 49 ms
14,736 KB
testcase_22 AC 42 ms
11,240 KB
testcase_23 AC 5 ms
8,652 KB
testcase_24 AC 60 ms
21,348 KB
testcase_25 AC 37 ms
15,312 KB
testcase_26 AC 10 ms
8,464 KB
testcase_27 WA -
testcase_28 AC 91 ms
34,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<ctime>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<bitset>
#include<functional>
#include <fstream>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
#define puts(x) cout << (x) << "\n"
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const int intINF = 1000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;
//const ld EPS = 1e-9;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
//main関数内に extGCD(a, b, x, y); でx, yに解が格納
ll extGCD(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);
typedef pair <ll, ll> P;
typedef pair <ld, ll> pp;
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
struct edge { ll to, cost; };
struct status {
	ll ima;
	ll cost;
	ll p;

	bool operator<(const status& rhs) const { return cost < rhs.cost; };
	bool operator>(const status& rhs) const { return cost > rhs.cost; };
};

//const ll INF = 10000000000000;
//struct edge { ll to, cost; };
//typedef pair<ll, ll>P; //firstは最短距離、secondは頂点番号
ll dn = INF, n, m;//始点sから終点tまでのコストd[t]
vector<edge> G[213456];//コスト
vector<ll>t(10005);
void dijkstra(ll s) {
	//greater<P>を指定→firstが小さい順
	priority_queue<status, vector<status>, greater<status> >que;
	//fill(d, d + 213456, INF);//←TLE気を付ける
	/*d[s] = t[s];*/ que.push({ s, t[s], t[s] });
	ll cnt = 0;
	while (!que.empty()) {
		status q = que.top(); que.pop(); cnt++;
		if (cnt >= 200000) { break; }
		int v = q.ima;
		if (v == n) { dn = min(dn, q.cost); continue; }
		//if (d[v] < q.cost) { continue; }
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			que.push({ e.to, q.cost + (e.cost / q.p) + t[e.to], q.p + t[e.to] });
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	//cout << fixed << setprecision(15);

	//input
	cin >> n >> m;
	rep(i, m) {
		ll a, b, c; cin >> a >> b >> c;
		G[a].push_back({ b,c }); G[b].push_back({ a,c });
	}
	rep2(i, n) { cin >> t[i]; }
	dijkstra(1);
	cout << dn << endl;
	return 0;
}
0