bzoj1222
2024-09-02 06:57:28
奇怪的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 ;
}
最新文章
- Entity Framework 6 Recipes 2nd Edition(10-7)译 ->; TPH继承模型中使用存储过程
- .stop()
- Notes for Studying Django
- 理解 OpenStack + Ceph (5):OpenStack 与 Ceph 之间的集成 [OpenStack Integration with Ceph]
- centos下载jdk
- ==,equal,hasCode(),identifyHasCode()浅析
- 一些实用的 jQuery 技巧
- Google JavaScript 语言规范
- Eclipse SVN插件的帐号、password改动
- 摩根斯坦利 - 2016年09月8日 面试题 - HashMap
- POJ 3111 K Best
- 简单介绍如何使用robotium进行自动化测试
- Sharepoint对List增删改操作
- 最近面试 Java 后端开发的感受!
- nginx的proxy_redirect
- React 设计模式 --- Container and Presentational pattern(容器和展示组件分离)
- python 阿狸的进阶之路(5)
- 【BZOJ1044】[HAOI2008]木棍分割(动态规划,贪心)
- centos7 修改中文字符集 How to avoid having to `export LC_ALL=“zh_CN.UTF-8”` upon each SSH connection
- PAT 1066 Root of AVL Tree[AVL树][难]
热门文章
- 创建pycharm项目时项目解释器的选择
- CSS3中transition-duration參数对hover前后两种过渡时间的影响
- Solidworks工程图如何使用,替换图纸格式模板文件
- SolidEdge 装配体中如何快速的搞定一个面上所有螺丝 如何在装配体上进行阵列
- jobject和jclass
- Ubuntu 14.04安装搜狗拼音linux版应该注意的问题
- BusHelper
- Android Webview的测试
- 在vc6.0下编的对话框界面如果没做过其他处理,往往显的很生硬,怎么样才能使他有Windows XP的风格呢,其实也很简单,我们来看看下面两种方法。
- hadoop 一些文件操作