hdu1158 Employment Planning 2016-09-11 15:14 33人阅读 评论(0) 收藏
Employment Planning
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5151 Accepted Submission(s): 2208
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.
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'.
3
4 5 6
10 9 11
0
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) 收藏的更多相关文章
- Toad for MySQL 7.3 Freeware异常 2017-01-09 15:14 115人阅读 评论(0) 收藏
打开Toad出现如下异常信息: 解决办法: 重装.NET Framework4.0
- TextView之一:子类的常用属性 分类: H1_ANDROID 2013-10-30 15:14 770人阅读 评论(0) 收藏
TextView常见的子类包括EditText,Button,CheckBox, RadioButton等. 1.EditText EditText继承自TextView,因此TextView所有属性 ...
- 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 ...
- Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏
Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21767 Accepted: 13641 Desc ...
- 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 ...
- Oracle垃圾数据清理相关问题 分类: Oracle 2015-08-06 11:14 12人阅读 评论(0) 收藏
垃圾数据清理,简单的说,就是删除不需要的那些数据,释放存储空间 最常用的就是delete命令.truncate命令,甚至是删除表空间重建,具体操作都很简单,不是本文的重点 下面,总结几个垃圾数据清理常 ...
- 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 ...
- Jsp Cookie的创建与读取 标签: cookiejsp 2016-11-17 15:14 61人阅读 评论(0)
Cookie.jsp <%@ page language="Java" import="java.util.*" pageEncoding="u ...
- 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 ...
随机推荐
- The 2018 Nobel prizesThe Nobel prize for economics is awarded for work on the climate and economic growth
The 2018 Nobel prizesThe Nobel prize for economics is awarded for work on the climate and economic g ...
- Haskell语言学习笔记(60)Biapplicative
Biapplicative class Bifunctor p => Biapplicative p where bipure :: a -> b -> p a b (<< ...
- nodejs文件操作笔记
nodejs添加了流的概念,通过流操作文件如行云流水,比早前便利畅快多了. 先来第一个例子,我们建一个stream.js文件,里面内容如下: var fs = require("fs&quo ...
- nginx+redis+4个tomcat 负载均衡
1,先配置nginx ,如果80接口被占用,且80 的端口又惹不起,参考:https://www.cnblogs.com/xiaohu1218/p/10267602.html 2,下载redis,并配 ...
- Conductor Task Workers
由远程worker执行的conductor任务通过HTTP端点进行通信以轮询任务并更新执行状态. conductor提供了轮询任务的框架,管理执行线程并将执行状态更新回服务器.该框架提供了Java和P ...
- Android 最火开发框架 xUtils
xUtils简介 xUtils3 api变化较多, 已转至 https://github.com/wyouflf/xUtils3 xUtils 2.x对Android 6.0兼容不是很好, 请尽快升级 ...
- ios 处理WKContentView的crash
http://www.jianshu.com/p/7ef5814a871b 解决WKContentView没有isSecureTextEntry方法造成的crash 程序中有web页面,使用W ...
- UVa 12100 Printer Queue(queue或者vector模拟队列)
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- SweetAlert2 弹窗
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- win 下 nginx 的虚拟主机创建
1.在nginx安装目录下的conf下创建vhost目录,用于存放虚拟主机配置文件. 2.在nginx安装目录下的conf/nginx.conf的http{}中加入 include vhost/* ...