結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  kapo | 
| 提出日時 | 2016-05-30 14:42:24 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 874 bytes | 
| コンパイル時間 | 459 ms | 
| コンパイル使用メモリ | 56,636 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-07 18:01:56 | 
| 合計ジャッジ時間 | 1,459 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 WA * 10 | 
ソースコード
#include <iostream>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
#define INF 1e9
int main(void)
{
	int N, M;
	cin >> N;
	int S[50];
	rep(i,0,N) cin >> S[i];
	S[0] = S[N-1] = INF;
	cin >> M;
	int G[50][50];
	int from, to, cost;
	rep(i,0,N) rep(j,0,N) G[i][j] = INF;
	rep(i,0,M) {
		cin >> from >> to >> cost;
		G[from][to] = cost;
		G[to][from] = cost;
	}
	rep(i,0,N) G[i][i] = 0;
	rep(k,0,N) rep(i,0,N) rep(j,0,N) {
		if(G[i][j] > G[i][k] + G[k][j]) G[i][j] = G[i][k] + G[k][j];
	}
	// rep(i,0,N) rep(j,0,N) printf("G[%d][%d] = %d\n",i,j,G[i][j]);
	int ans = INF;
	rep(i,0,N) rep(j,0,N) {
		if(i == j) continue;
		if(ans > G[0][i] + G[i][j] + G[j][N-1] + S[i] +S[j]) {
			ans = G[0][i] + G[i][j] + G[j][N-1] + S[i] +S[j];
			// printf("i=%d j=%d ans=%d\n",i,j,G[0][i] + G[i][j] + G[j][N-1] + S[i] +S[j]);
		}
	}
	cout << ans << endl;
	return 0;
}
            
            
            
        