HDU1158:Employment Planning(暴力DP)
Employment Planning
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7097 Accepted Submission(s): 3034
4 5 6
10 9 11
0

#define _CRT_SECURE_NO_DepRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cctype>
#include <iterator>
#include <vector>
#include <cstring>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define ll long long
#define INF 0x3f3f3f3f
#define ld long double
const ld pi = acos(-.0L), eps = 1e-;
int qx[] = { ,,,- }, qy[] = { ,-,, }, qxx[] = { ,- }, qyy[] = { ,- };
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
int hire, salary, fire, need[], dp[][], max, ans;
while (cin >> n && n)
{
memset(dp, , sizeof(dp));
max = ;
ans = INF;
cin >> hire >> salary >> fire;
for (int i = ; i < n; i++)
{
cin >> need[i];
max = ::max(need[i], max);//记录最多需要的人
}
for (int i = need[]; i <= max; i++)//先初始化第一个月需要的钱,枚举从一月最少需要的人到最多需要的人
{
dp[][i] = i * (hire + salary);
}
for (int i = ; i < n; i++)
{
for (int f = need[i]; f <= max; f++)//枚举从最少需要的人到最多需要的人的情况花费的钱
{
dp[i][f] = INF;
for (int h = need[i - ]; h <= max; h++)//与上个月的每种情况进行对比
{
if (h <= f)//人数少于或等于需要的人数
{
dp[i][f] = min(dp[i][f], dp[i - ][h] + (f - h) * hire + f * salary);
}
else//人数多于需要的人数
{
dp[i][f] = min(dp[i][f], dp[i - ][h] + (h - f) * fire + f * salary);
}
}
}
}
for (int i = need[n - ]; i <= max; i++)//找到最小值
{
ans = min(ans, dp[n - ][i]);
}
cout << ans << endl;
}
return ;
}
HDU1158:Employment Planning(暴力DP)的更多相关文章
- hdu1158 Employment Planning(dp)
题目传送门 Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- 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/Othe ...
- HDU 1158 Employment Planning【DP】
题意:给出n个月,雇佣一个人所需的钱hire,一个人工作一个月所需要的钱salary,解雇一个人所需要的钱fire,再给出这n个月每月1至少有num[i]个人完成工作,问完成整个工作所花费的最少的钱是 ...
- HDU 1158 Employment Planning (DP)
题目链接 题意 : n个月,每个月都至少需要mon[i]个人来工作,然后每次雇佣工人需要给一部分钱,每个人每个月还要给工资,如果解雇人还需要给一笔钱,所以问你主管应该怎么雇佣或解雇工人才能使总花销最小 ...
- hdu 1158 Employment Planning(DP)
题意: 有一个工程需要N个月才能完成.(n<=12) 给出雇佣一个工人的费用.每个工人每个月的工资.解雇一个工人的费用. 然后给出N个月所需的最少工人人数. 问完成这个项目最少需要花多少钱. 思 ...
- Employment Planning[HDU1158]
Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Employment Planning DP
Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- hdu 1158 dp Employment Planning
Employment Planning Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- Employment Planning
Employment Planning 有n个月,每个月有一个最小需要的工人数量\(a_i\),雇佣一个工人的费用为\(h\),开除一个工人的费用为\(f\),薪水为\(s\),询问满足这n个月正常工 ...
随机推荐
- python学习列表(Lists).基础二
列表(Lists) 序列是Python中最基本的数据结构,序列中的每个元素都分配一个数字,它的第一个索引是0第二个索引是1,依次类推. 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号 ...
- Docker 使用杂记 - 最佳实践尝试 - 实战
目录 Docker 使用杂记 - 最佳实践尝试 - 实战 Docker简介 项目背景 内在原因 外在原因 基础镜像 需求 镜像维护者 工作文件夹 文件 ADD COPY 宗卷 命令 入口点 Docke ...
- vscode C++ 程序 windows
vscode 1.42.1 OS: windows 7 x64 1. vscode, cpp extension 本文直接跳过 vscode 安装, Cpp tools 安装 2. MinGw 安装及 ...
- 2019计蒜客信息学提高组赛前膜你赛 #2(TooYoung,TooSimple,Sometimes Naive
计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):&qu ...
- activiti工作流解决历史批注中文乱码
/** * 根据流程实例查询流程的批注信息 * * @param processInstanceId * @return */ private List<Comment> findComm ...
- 聊聊count(*)
count(*) 的实现方式 MyISAM 引擎把一个表的总行数存在了磁盘上,因此执行 count(*) 的时候会直接返回这个数,效率很高 InnoDB 引擎就麻烦了,它执行 count(*) 的时候 ...
- iconfont字体图标的使用方法(转)
我之前因为项目用bootstrap比较多,所以使用font awesome字体图标比较多,后来接触到了iconfont,发现想要的什么图标都有,还可以自定义图标,非常强大!之前看了一波教程,觉得繁琐, ...
- 关于WPF System.windows.Media.FontFamily 的类型初始值设定项引发异常问题解决方法
造成原因:此问题的根本原因是.NET Framework January 2018 Rollup(KB4055002)与已安装的.NET Framework 4.7.1产品版本之间的MSI安装交互.R ...
- quagga/zebra - 交叉编译(cross)和本地编译(native)
https://github.com/dramalife/note.git AUTHOR : Dramalife@live.com Init : 2020.03.19 Update : source ...
- SCF(SenparcCoreFramework) 系列教程(一):项目介绍及快速搭建
2020年3月25日的“盛派周三分享”活动首次使用直播的方式与大家见面,共有 500 多人参与了活动,得到了众多开发者的好评,并强烈要求我分享 PPT,这点要求当然必须满足啦! 除此以外,还有许多开发 ...