/*
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,int> pi ;
#define if1(x) for(int i =1 ;i<=x;i++)
#define if0(x) for(int i = 0;i<x;i++)
#define jf0(x) for(int j = 0;j<x;j++)
#define jf1(x) for(int j = 1;j<=x;j++)
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const ll N = 2*1005*1005;
ll MAXX = 0x3f3f3f3f3f3f3f3f;
int n,a,b,c;
bool vis[2005];
ll m;
ll w[N],dist[2005];
int e[N],h[N],ne[N],idx;
void add(int a,int b,ll c){
w[idx] = c;
e[idx] = b;
ne[idx] = h[a];
h[a] =idx++;
}
void dijict(int x){
dist[x] = 0;
priority_queue<pi, vector<pi>, greater<pi>>mq;
mq.push({0,x});//距离和点
while(!mq.empty()){
ll distence = mq.top().first;
int cite = mq.top().second;
mq.pop();
if(vis[cite])continue;
vis[cite] = 1;
for(int j = h[cite];j!=-1;j = ne[j]){
int o = e[j];
ll ww = w[j];
if(1ll*distence+ww<dist[o]){
dist[o] = distence+ww;
mq.push({dist[o],o});
}
}
}
}
void solve(){
cin>>n>>a>>b>>c;
memset(h,-1,sizeof(h));
memset(vis,0,sizeof(vis));
if1(2*n+2)dist[i] = MAXX;
if1(n){
jf1(n){
cin>>m;
//by car
add(i,j,m*a);
//by train
add(i+n,j+n,m*b+c);
}
}
dijict(1);
dijict(2*n);
ll ans = MAXX;
if1(n) ans = min(ans,dist[i]+dist[i+n]);
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
// getchar();
return 0;
}
tempp
最新推荐文章于 2024-08-31 22:41:09 发布