結果
| 問題 |
No.17 2つの地点に泊まりたい
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-07-14 01:39:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 930 bytes |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 171,944 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-02 22:33:09 |
| 合計ジャッジ時間 | 2,261 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000009
//#define MOD 998244353
#define INF 1000000000
//#define INF 1000000000000000000
int main(){
int N;
cin>>N;
vector<int> S(N);
for(int i=0;i<N;i++){
cin>>S[i];
}
vector<vector<int>> dist(N,vector<int>(N,INF));
int M;
cin>>M;
for(int i=0;i<M;i++){
int a,b,c;
cin>>a>>b>>c;
dist[a][b]=min(dist[a][b],c);
dist[b][a]=min(dist[b][a],c);
}
for(int k=0;k<N;k++){
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
int ans=INF;
for(int i=1;i<N-1;i++){
for(int j=1;j<N-1;j++){
if(i==j){
continue;
}
ans=min(ans,dist[0][i]+dist[i][j]+dist[j][N-1]+S[i]+S[j]);
}
}
cout<<ans<<endl;
}
monnu