HDU_1158_Employment Planning_dp
Employment Planning
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4846 Accepted Submission(s): 2061
4 5 6
10 9 11
0
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define INF 999999999
int mon[];
int dp[][];
int main()
{
int n,hire,fire,sala;
while(scanf("%d",&n)!=EOF&&n)
{
//memset(dp,0,sizeof(dp));
scanf("%d%d%d",&hire,&sala,&fire);
int maxn=;
for(int i=; i<=n; i++)
{
scanf("%d",&mon[i]);
if(maxn<mon[i])
maxn=mon[i];
}
for(int i=; i<=; i++)
for(int j=; j<=; j++)
dp[i][j]=INF;
for(int i=; i<=n; i++)
for(int j=mon[i]; j<=maxn; j++)
if(i==)
dp[i][j]=j*(sala+hire);
else
{
for(int k=mon[i-]; k<=maxn; k++)
if(j>=k)
dp[i][j]=min(dp[i][j],dp[i-][k]+(j-k)*(sala+hire)+k*sala);
else
dp[i][j]=min(dp[i][j],dp[i-][k]+(k-j)*fire+j*sala);
}
//cout<<dp[1][10]<<'*'<<dp[1][11]<<endl;
// cout<<dp[2][9]<<'*'<<dp[2][10]<<'*'<<dp[2][11]<<endl;
// cout<<dp[3][11]<<endl;
int ans=INF;
for(int i=mon[n]; i<=maxn; i++)
if(ans>dp[n][i])
ans=dp[n][i];
printf("%d\n",ans);
} return ;
}
HDU_1158_Employment Planning_dp的更多相关文章
随机推荐
- Linux下Ubuntu 操作系统 部署
1.1 先更新系统 环境 更新命令为: apt-get update 1.2 安装jdk 安装JDK命令为:sudo apt-get install o penjdk-7-jdk 1.3 安装tomc ...
- some notes about ADDM and AWR
Use the sophisticated management and monitoring features of the Oracle DatabaseDiagnostic and Tuning ...
- influxDB系列(二)--查看数据库的大小
google 搜索了好多文档,终于发现了这个靠谱的回答. https://groups.google.com/forum/#!topic/influxdb/I5eady_Ta5Y You can se ...
- V Server Ubuntu
Ubuntu下代理伺服器通常使用squid 安裝 sudo apt-get install squid 修改squid.conf配置 sudo vim /etc/squid/squid.conf 公司 ...
- ubuntu刪除升級后多余的内核
列出所安装的内核 带有image的就是内核文件dpkg --get-selections|grep linuxlibselinux1 installlinux-386 installlinux-ima ...
- LeetCode 246. Strobogrammatic Number (可颠倒数字) $
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
- Linux 下查找文件或文件夹
有些在我看来比较实用的命令,在这里记一下,避免每次都搜索一轮. 1.查找文件和文件夹 $ find . -name "mongo*" 从当前路径开始,向子目录查找名字含有 &quo ...
- TLabel和TEdit的初次显示过程
procedure TForm1.Button2Click(Sender: TObject); var l: TLabel;begin l:=TLabel.Create(self); l.Name:= ...
- 53. 部门信息显示 EXTJS 单击树节点
1. /** * @author sux * @time 2011-1-14 * @desc 部门信息显示 */ deptInfoGridPanel = Ext.extend(Ext.grid.Edi ...
- codevs1026商务旅行
1036 商务旅行 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 某首都城市的商人要经常到各城镇去做 ...