找出权值最小的点,让其余的点与该点相连
#include<bits/stdc++.h> using namespace std; #define int long long const int maxn=500000; int head[maxn],f[maxn],a[maxn],cnt; signed main() { int n,min1=1e9,sum=0; cin>>n; for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i],min1=min(min1,a[i]); sum+=(n-2)*min1; cout<<sum; }