[JSOI2008]Blue Mary的职员分配
2024-10-10 19:15:36
由于Blue Mary呕心沥血的管理,Blue Mary的网络公司蒸蒸日上。现在一共拥有了n名职员,可惜没有任何的金钱和声誉。平均每名每天职员都可以给公司带来x单位金钱或者y单位声誉(名利不能双全)。并且可以花费z单位的金钱在人才交易市场发布广告招聘职员,每次发布广告三天以后就会招聘到一名职员,并且必须在发布广告并且招聘到职员的那一天才能发布下一次广告。
Blue Mary计划以最快的时间获得至少A单位金钱和至少B单位声誉,请你计算一下他至少需要多少时间才能达到他的目标。
Solution
看着是个暴力dp,但要注意转移方向。
单纯获利是,从钱少的的地方向钱多的地方转移。
发广告时,从等待天数少的向天数多的地方转移,但钱会减少。
连续发广告是,从人少向人多转移,钱会减少。
我们的枚举顺序确定了,人,等待天数,钱,名誉。
Code
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int dp[][][][],n,x,y,z,a,b,ans;
int main(){
scanf("%d%d%d%d%d%d",&n,&x,&y,&z,&a,&b);memset(dp,0x3f,sizeof(dp));
dp[n][][][]=;
ans=;
for(int i=n;i<=;++i)
for(int t=;t<=;++t)
for(int j=;j<=max(a,z);++j)
for(int k=;k<=b;++k)
if(dp[i][j][k][t]<ans)
{
if(j>=a&&k>=b)ans=min(ans,dp[i][j][k][t]);
for(int l=;l<=i;++l){
int ma=min(j+l*x,max(a,z)),mb=min(k+(i-l)*y,b);
if(!t){
dp[i][ma][mb][]=min(dp[i][ma][mb][],dp[i][j][k][]+);
if(ma>=z)dp[i][ma-z][mb][]=min(dp[i][ma-z][mb][],dp[i][j][k][]+);
}
else if(t<)
dp[i][ma][mb][t+]=min(dp[i][ma][mb][t+],dp[i][j][k][t]+);
else {
dp[i+][ma][mb][]=min(dp[i+][ma][mb][],dp[i][j][k][t]+);
dp[i+][ma-z][mb][]=min(dp[i+][ma-z][mb][],dp[i][j][k][t]+);
}
}
}
cout<<ans;
return ;
}
最新文章
- 薪资至少10K的一道题,你能拿下吗
- ios枚举规范
- java 顺序 读写 Properties 配置文件
- POJ 2549 Sumsets hash值及下标
- sysctl命令详解
- scala一些高级类型
- settings.xml
- HTTP相关知识 --转载
- 腾讯TDW:大型Hadoop集群应用[转载]
- PHP自学3——在html的<;table>;标签中显示用户提交表单
- 使用gson(一)
- 如何在Unity中分别实现Flat Shading(平面着色)、Gouraud Shading(高洛德着色)、Phong Shading(冯氏着色)
- SQL Server中INNER JOIN与子查询IN的性能测试
- Markdown编辑后
- soapUI启动报错:The JVM could not be started. The maximum heap size (-Xmx) might be too large or an antivirus or firewall tool could block the execution.
- python中 __init__.py的例程
- 2019-03-25-day018-面向对象
- c#中委托与事件
- One difference between AngularJS&#39; $location and window.location
- PyQt5--QFontDiaglog
热门文章
- Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval o
- Windows10 Build 18298 桌面显示计算机(此电脑)
- MySQL 5.7默认ONLY_FULL_GROUP_BY语义介绍
- switch变种玩法
- spring AOP源码分析(三)
- picker-view 组件 的value失效问题
- Eclipse中Maven的简单使用
- Socket和ObjectOutputStream问题
- 压测工具使用(vegeta)
- 关于Linux系统下jdk版本切换问题(alternatives命令的使用)