Employment Planning

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 5151    Accepted Submission(s): 2208

Problem Description
A project manager wants to determine the number of the workers needed in every month. He does know the minimal number of the workers needed in each month. When he hires or fires a worker, there will be some extra cost. Once a worker is hired, he will get the
salary even if he is not working. The manager knows the costs of hiring a worker, firing a worker, and the salary of a worker. Then the manager will confront such a problem: how many workers he will hire or fire each month in order to keep the lowest total
cost of the project. 
 
Input
The input may contain several data sets. Each data set contains three lines. First line contains the months of the project planed to use which is no more than 12. The second line contains the cost of hiring a worker, the amount of the salary, the cost of firing
a worker. The third line contains several numbers, which represent the minimal number of the workers needed each month. The input is terminated by line containing a single '0'.
 
Output
The output contains one line. The minimal total cost of the project.
 
Sample Input
3
4 5 6
10 9 11
0
 
Sample Output
199
 

本题的意思是给出给出雇佣一个工人的钱,工人每月的钱,和解雇工人的钱,和每月所需工人,算出最小花费。

想法就是把每月雇佣多少个工人的费用全保存下来,for跑一遍找出得到上月雇佣j个到本月的雇佣k个工人所需的最小花费,第一个月特殊处理

这题没给每月工人个数,我那100做过了

代码如下

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define inf 0x3f3f3f3f int dp[15][110];
int e,f,s;
int a[15]; int main()
{
int n;
int mn;
while(~scanf("%d",&n)&&n)
{
scanf("%d%d%d",&e,&s,&f);
for(int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
for(int i=0; i<110; i++)
{
dp[1][i]=(e+s)*i;
}
for(int i=2;i<=n;i++)
{
for(int j=a[i];j<110;j++)//本月至少要a[i]个人
{
mn=inf;
for(int k=a[i-1];k<110;k++)//上月必须要到a[i-1]个人才符合
{
if(k<=j)
mn=min(mn,dp[i-1][k]+k*s+(j-k)*(s+e));//人增多,多雇佣
else
mn=min(mn,dp[i-1][k]+j*s+(k-j)*f);//人减少,解雇
}
dp[i][j]=mn;
}
}
mn=inf;
for(int i=a[n];i<110;i++)
{
mn=min(mn,dp[n][i]);
}
printf("%d\n",mn); }
return 0;
}

hdu1158 Employment Planning 2016-09-11 15:14 33人阅读 评论(0) 收藏的更多相关文章

  1. Toad for MySQL 7.3 Freeware异常 2017-01-09 15:14 115人阅读 评论(0) 收藏

    打开Toad出现如下异常信息: 解决办法: 重装.NET Framework4.0

  2. TextView之一:子类的常用属性 分类: H1_ANDROID 2013-10-30 15:14 770人阅读 评论(0) 收藏

    TextView常见的子类包括EditText,Button,CheckBox, RadioButton等. 1.EditText EditText继承自TextView,因此TextView所有属性 ...

  3. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

    1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

  4. Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏

    Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21767   Accepted: 13641 Desc ...

  5. Curling 2.0 分类: 搜索 2015-08-09 11:14 3人阅读 评论(0) 收藏

    Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14289 Accepted: 5962 Descript ...

  6. Oracle垃圾数据清理相关问题 分类: Oracle 2015-08-06 11:14 12人阅读 评论(0) 收藏

    垃圾数据清理,简单的说,就是删除不需要的那些数据,释放存储空间 最常用的就是delete命令.truncate命令,甚至是删除表空间重建,具体操作都很简单,不是本文的重点 下面,总结几个垃圾数据清理常 ...

  7. Hdu4632 Palindrome subsequence 2017-01-16 11:14 51人阅读 评论(0) 收藏

    Palindrome subsequence Problem Description In mathematics, a subsequence is a sequence that can be d ...

  8. Jsp Cookie的创建与读取 标签: cookiejsp 2016-11-17 15:14 61人阅读 评论(0)

    Cookie.jsp <%@ page language="Java" import="java.util.*" pageEncoding="u ...

  9. Velocity浅析及与Jsp、Freemarker对比 分类: B1_JAVA 2014-07-21 09:14 637人阅读 评论(0) 收藏

    转载自:http://www.cnblogs.com/petermsdn/archive/2011/05/06/2039178.html Velocity 是一个基于java 的模板引擎(templa ...

随机推荐

  1. Unity C# 调用 C++ DLL 并在 DLL 中调用 C# 的回调函数

    Unity C# 调用 C++ DLL 并在 DLL 中调用 C# 的回调函数~~~    呵呵... 看着有点晕.. 再解释一下就是 在Unity中 使用 C# 调用 C++ 写的 DLL, 但是在 ...

  2. centos7 升级python2.7 到python3.6(Centos7 安装Anaconda)

    Anaconda 下载 https://www.anaconda.com/download/#linux 下载文件 Anaconda3-5.2.0-Linux-x86_64.sh bash Anaco ...

  3. racktables 的介绍及搭建指南

    Racktables RackTables称自己为一个“机架空间.IP地址.服务器.交换机.路由器等 的管理框架”.它拥有一个web界面,执行报告和配置,并管理名字服务.RackTables以PHP5 ...

  4. 1.Two Sum (Array; HashTable)

    Given an array of integers, find two numbers such that they add up to a specific target number. The ...

  5. Web服务技术协议:REST与SOAP

    Web服务技术就有SOAP(Simple Object Access Protocol,简单对象访问协议)和REST(Representational State Transfer,表示性状态转移) ...

  6. 清空表中数据 id从1开始

    删除表的记录以后,如何使新记录的编号仍然从1开始有两种方法: 方法1: truncate table 你的表名 --这样不但将数据删除,而且可以重新置位identity属性的字段. 方法2: dele ...

  7. Linux中chown、chmod、chgrp

    1.chgrp (转变文件所属用户组) chgrp(转变文件所属用户组)change group chgrp 用户组 文件名 ###便是这个格了.若是整个目次下的都改,则加-R参数用于递归. 如:ch ...

  8. discuz回贴通知插件实现-插件的多语言

    如果涉及到页面的展示,模板,提示信息,通常会   1.建立好需要的文字的翻译 在disucz的data/plugindata目录创建一个插件所使用的语言文件,命名方式为: 插件标识符.lang.php ...

  9. yii的layouts的使用

    yii的layouts的使用 我们在控制器中使用render()时,yii会默认的载入布局. 1.在protected/componets下的Controller.php中修改$layout变量, 来 ...

  10. Mininet

    在Coursera SDN开放课程中,编程作业要用Mininet来完成.这里对Mininet做一个简单的介绍. 什么是Mininet Mininet是由一些虚拟的终端节点(end-hosts).交换机 ...