結果
| 問題 |
No.17 2つの地点に泊まりたい
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-17 15:23:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,104 bytes |
| コンパイル時間 | 1,350 ms |
| コンパイル使用メモリ | 162,660 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-02 21:26:43 |
| 合計ジャッジ時間 | 2,248 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)
typedef long long ll;
typedef long double ld;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(0);
int n;
cin >> n;
vector<int> s(n);
rep (i, n) cin >> s[i];
int m;
cin >> m;
vector<vector<int> > g(n, vector<int>(n, Inf));
rep (i, n) g[i][i] = 0;
rep (i, m) {
int a, b, c;
cin >> a >> b >> c;
g[a][b] = g[b][a] = c;
}
rep (k, n) {
rep (i, n) {
rep (j, n) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
ll res = Inf;
FOR (i, 1, n - 1) {
FOR (j, 1, n - 1) {
if (i == j) continue;
ll tmp = 0;
tmp += s[i] + s[j];
tmp += g[0][i] + g[i][j] + g[j][n - 1];
res = min(res, tmp);
}
}
cout << res << endl;
return 0;
}