标签:std 枚举 define eof planning 工资 需要 space etc
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
int Need[15],f[15][10005];
int main(){
while(1){
int n=read();if(!n)break;
int a=read(),b=read(),c=read(),maxn=0;
for(int i=1;i<=n;++i)Need[i]=read(),maxn=max(maxn,Need[i]);
memset(f,0x3f,sizeof(f));f[0][0]=0;
for(int i=1;i<=n;++i)
for(int j=Need[i];j<=maxn;++j)
for(int k=Need[i-1];k<=maxn;++k){
if(j<k)f[i][j]=min(f[i][j],f[i-1][k]+b*j+c*(k-j));
else if(j==k)f[i][j]=min(f[i][j],f[i-1][k]+b*j);
else if(j>k)f[i][j]=min(f[i][j],f[i-1][k]+a*(j-k)+b*j);
}
int ans=1e9;
for(int i=Need[n];i<=maxn;++i)ans=min(ans,f[n][i]);
printf("%d\n",ans);
}
return 0;
}
标签:std 枚举 define eof planning 工资 需要 space etc
原文地址:https://www.cnblogs.com/PPXppx/p/11426793.html