标签:number mil define red fine for rip Plan family
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6242 Accepted Submission(s): 2710
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mod 1000000007
#define INF 0x3f3f3f3f
int n;
int people[13];
int dp[13][10000];
int hire,salary,fire;
int main()
{
while(cin>>n)
{
if(n==0) break;
cin>>hire>>salary>>fire;
int maxn=0;
for(int i=1;i<=n;i++)
{
cin>>people[i];
maxn=max(maxn,people[i]);
}
memset(dp,INF,sizeof(dp));
for(int i=people[1];i<=maxn;i++)
dp[1][i]=i*salary+i*hire;
for(int i=2;i<=n;i++)
{
for(int j=people[i];j<=maxn;j++)
{
for(int k=people[i-1];k<=maxn;k++)
{
if(k<=j)
dp[i][j]=min(dp[i][j],dp[i-1][k]+j*salary+(j-k)*hire);
else
dp[i][j]=min(dp[i][j],dp[i-1][k]+j*salary+(k-j)*fire);
}
}
}
int minn=INF;
for(int i=people[n];i<=maxn;i++)
{
minn=min(minn,dp[n][i]);
}
cout<<minn<<endl;
}
return 0;
}
hdu1158 Employment Planning(dp)
标签:number mil define red fine for rip Plan family
原文地址:https://www.cnblogs.com/zhgyki/p/9595420.html