結果

問題 No.17 2つの地点に泊まりたい
ユーザー こるこる
提出日時 2017-02-16 19:06:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,022 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 65,928 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 17:40:17
合計ジャッジ時間 1,816 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VLL vector<ll,ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define OUT(n) cout<<n<<endl
#define TS(n) to_string(n)

using namespace std;

ll dist[51][51];

void floyd(ll n) {
	rep(k, n) rep(i, n) rep(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}

int main() {
	ll n; cin>>n;
	ll s[50],a,b,c;
	rep(i, n) cin>>s[i];
	ll m; cin>>m;
	rep(i, n) rep(j, n) dist[i][j] = INF;
	rep(i, m){
		cin>>a>>b>>c;
		dist[a][b] = dist[b][a] = c;
	}
	floyd(n);
	ll temp ,ans=INF;
	nrep(i, 1, n - 1) nrep(j, 1, n - 1) if (i != j) {
			temp = dist[0][i] + dist[i][j] + dist[j][n - 1] + s[i] + s[j];
			OUT(TS(i) + " j=" + TS(j));
			ans = min(ans, temp);
	}OUT(ans);
	return 0;
}
0