結果
問題 | No.17 2つの地点に泊まりたい |
ユーザー |
![]() |
提出日時 | 2017-02-16 19:06:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 66,032 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 00:21:59 |
合計ジャッジ時間 | 2,222 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 27 |
ソースコード
#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;}