結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  wk1080id | 
| 提出日時 | 2019-05-24 00:31:55 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 1,458 bytes | 
| コンパイル時間 | 769 ms | 
| コンパイル使用メモリ | 84,264 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-17 09:57:59 | 
| 合計ジャッジ時間 | 1,464 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
ソースコード
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}
signed main(void) {
    int n;
    cin >> n;
    vi s(n);
    rep(i,n)cin >> s[i];
    int m;
    cin >> m;
    int v[55][55];
    rep(i,n)rep(j,n)v[i][j] = INF;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        v[a][b] = v[b][a] = c;
    }
    rep(k,n)rep(i,n)rep(j,n){
        v[i][j] = min(v[i][j],v[i][k]+v[k][j]);
    }
    int ans = INF;
    loop(i,1,n-1)loop(j,1,n-1)if(i != j){
        int t = v[0][i]+v[i][j]+v[j][n-1]+s[i]+s[j];
        //cout << i << " " << j <<  " " << t << endl;
        ans = min(ans, t);
    }
    cout << ans << endl;
}
            
            
            
        