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的更多相关文章
随机推荐
- springboot跨域请求设置
当它请求的一个资源是从一个与它本身提供的第一个资源的不同的域名时,一个资源会发起一个跨域HTTP请求(Cross-site HTTP request).比如说,域名A ( http://domaina ...
- VM Workstation中如何实现Linux系统的通信
1 确保虚拟机中的Linux是NAT联网方式 2确保Vmware Network Adapter VMnet1和 VMnet8 都是"已启用"状态,如果是"未识别的网 ...
- Wireshark 抓包遇到 you don’t have permission to capture on that device mac 错误的解决方案
Wireshark 抓包遇到 you don’t have permission to capture on that device mac 错误的解决方案 上次有篇博客讲了如何利用wireshark ...
- iOS 设置启动页面 时间
[NSThread sleepForTimeInterval:3.0]; 时间越大 ,启动页面停留的时间越长 iOS 8之后,,创建项目自带的有 LaunchScreen.xib 可直接用
- 《天龙八部》及Ogre3D模型的3ds max导入插件(源码公布)
測试UE4项目.苦于没有像样的模型和动画资源,所以想到把<天龙八部>等网游的资源导出来用. 于是做了个max导入插件. 效果还是不错的. 效果图: 上图是<斗破苍穹>的游戏资源 ...
- objc_setAssociatedObject
学习笔记:通过 objc_setAssociatedObject alert 和 button关联 及传值 标签: ios 2013-11-22 16:25 7924人阅读 评论(1) 收藏 举报 ...
- Struts2之类型转换器的使用
一.学习案例:通过在输入页面(input.jsp)用同一个输入框同一时候输入username和password,通过类型转换器在输出页面(output.jsp)分别输出username和passwor ...
- Codeforces Round #272 (Div. 2) Dreamoon and WiFi 暴力
B. Dreamoon and WiFi Dreamoon is standing at the position 0 on a number line. Drazil is sending a li ...
- User32.dll详细介绍
RegisterServiceProcess(ProcessID:Long,Type:Long) 该函数存在于Kernal32.dll中. Process指向进程的ID,Type表示是否向系统注册该进 ...
- CF36 E Two Paths——欧拉(回)路
题目:http://codeforces.com/contest/36/problem/E 给定一张无向图,要求输出两条欧拉路覆盖所有边: 分类讨论,首先判-1:有两个以上连通块 / 有四个以上奇度数 ...