奇怪的dp

思路清奇 dp[i][j]表示当前做完了i个任务,1机器花了j秒,2机器花费的最少时间,然后转移就行了。

#include<bits/stdc++.h>
using namespace std;
const int N = ;
struct data {
int a, b, c;
} a[N];
int n, ans = 0x3f3f3f3f, pre;
int dp[][N * ];
int main()
{
scanf("%d", &n);
for(int i = ; i <= n; ++i)
{
scanf("%d%d%d", &a[i].a, &a[i].b, &a[i].c);
if(a[i].a == ) a[i].a = 0x3f3f3f3f;
if(a[i].b == ) a[i].b = 0x3f3f3f3f;
if(a[i].c == ) a[i].c = 0x3f3f3f3f;
}
for(int i = ; i <= n; ++i)
{
pre ^= ;
memset(dp[pre], 0x3f3f, sizeof(dp[pre]));
for(int j = ; j <= ; ++j)
{
if(j >= a[i].a) dp[pre][j] = dp[pre ^ ][j - a[i].a];
dp[pre][j] = min(dp[pre][j], dp[pre ^ ][j] + a[i].b);
if(j >= a[i].c) dp[pre][j] = min(dp[pre][j], dp[pre ^ ][j - a[i].c] + a[i].c);
}
}
for(int i = ; i <= ; ++i) ans = min(ans, max(i, dp[pre][i]));
cout << ans;
return ;
}

最新文章

  1. Entity Framework 6 Recipes 2nd Edition(10-7)译 -&gt; TPH继承模型中使用存储过程
  2. .stop()
  3. Notes for Studying Django
  4. 理解 OpenStack + Ceph (5):OpenStack 与 Ceph 之间的集成 [OpenStack Integration with Ceph]
  5. centos下载jdk
  6. ==,equal,hasCode(),identifyHasCode()浅析
  7. 一些实用的 jQuery 技巧
  8. Google JavaScript 语言规范
  9. Eclipse SVN插件的帐号、password改动
  10. 摩根斯坦利 - 2016年09月8日 面试题 - HashMap
  11. POJ 3111 K Best
  12. 简单介绍如何使用robotium进行自动化测试
  13. Sharepoint对List增删改操作
  14. 最近面试 Java 后端开发的感受!
  15. nginx的proxy_redirect
  16. React 设计模式 --- Container and Presentational pattern(容器和展示组件分离)
  17. python 阿狸的进阶之路(5)
  18. 【BZOJ1044】[HAOI2008]木棍分割(动态规划,贪心)
  19. centos7 修改中文字符集 How to avoid having to `export LC_ALL=“zh_CN.UTF-8”` upon each SSH connection
  20. PAT 1066 Root of AVL Tree[AVL树][难]

热门文章

  1. 创建pycharm项目时项目解释器的选择
  2. CSS3中transition-duration參数对hover前后两种过渡时间的影响
  3. Solidworks工程图如何使用,替换图纸格式模板文件
  4. SolidEdge 装配体中如何快速的搞定一个面上所有螺丝 如何在装配体上进行阵列
  5. jobject和jclass
  6. Ubuntu 14.04安装搜狗拼音linux版应该注意的问题
  7. BusHelper
  8. Android Webview的测试
  9. 在vc6.0下编的对话框界面如果没做过其他处理,往往显的很生硬,怎么样才能使他有Windows XP的风格呢,其实也很简单,我们来看看下面两种方法。
  10. hadoop 一些文件操作