由于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 ;
}

最新文章

  1. 薪资至少10K的一道题,你能拿下吗
  2. ios枚举规范
  3. java 顺序 读写 Properties 配置文件
  4. POJ 2549 Sumsets hash值及下标
  5. sysctl命令详解
  6. scala一些高级类型
  7. settings.xml
  8. HTTP相关知识 --转载
  9. 腾讯TDW:大型Hadoop集群应用[转载]
  10. PHP自学3——在html的&lt;table&gt;标签中显示用户提交表单
  11. 使用gson(一)
  12. 如何在Unity中分别实现Flat Shading(平面着色)、Gouraud Shading(高洛德着色)、Phong Shading(冯氏着色)
  13. SQL Server中INNER JOIN与子查询IN的性能测试
  14. Markdown编辑后
  15. 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.
  16. python中 __init__.py的例程
  17. 2019-03-25-day018-面向对象
  18. c#中委托与事件
  19. One difference between AngularJS&#39; $location and window.location
  20. PyQt5--QFontDiaglog

热门文章

  1. 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
  2. Windows10 Build 18298 桌面显示计算机(此电脑)
  3. MySQL 5.7默认ONLY_FULL_GROUP_BY语义介绍
  4. switch变种玩法
  5. spring AOP源码分析(三)
  6. picker-view 组件 的value失效问题
  7. Eclipse中Maven的简单使用
  8. Socket和ObjectOutputStream问题
  9. 压测工具使用(vegeta)
  10. 关于Linux系统下jdk版本切换问题(alternatives命令的使用)