AreYouBusy HDU - 3535 (dp)
AreYouBusy
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5176 Accepted Submission(s): 2069
As having become a junior, xiaoA recognizes that there is not much time for her to AC problems, because there are some other things for her to do, which makes her nearly mad.
What's more, her boss tells her that for some sets of duties, she must choose at least one job to do, but for some sets of things, she can only choose at most one to do, which is meaningless to the boss. And for others, she can do of her will. We just define the things that she can choose as "jobs". A job takes time , and gives xiaoA some points of happiness (which means that she is always willing to do the jobs).So can you choose the best sets of them to give her the maximum points of happiness and also to be a good junior(which means that she should follow the boss's advice)?
3 3
2 1
2 5
3 8
2 0
1 0
2 1
3 2
4 3
2 1
1 1 3 4
2 1
2 5
3 8
2 0
1 1
2 8
3 2
4 4
2 1
1 1 1 1
1 0
2 1 5 3
2 0
1 0
2 1
2 0
2 2
1 1
2 0
3 2
2 1
2 1
1 5
2 8
3 2
3 8
4 9
5 10
Sample Output
5
13
-1
-1
题意 :三类型工作,至多做一件至少做一件和随意做,问value的最大值
思路:多组背包,分类讨论
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=;
const double eps=1e-;
int c[],g[];
int dp[][];
int main()
{
int n,T,m,s,i,j,k;
while(~scanf("%d %d",&n,&T))
{
memset(dp,-,sizeof(dp));
memset(dp[],,sizeof(dp[]));
for(i=;i<=n;i++)
{
scanf("%d %d",&m,&s);
for(j=;j<m;j++)
scanf("%d%d",&c[j],&g[j]);
if(s==)
{
for(k=;k<m;k++)
for(j=T;j>=c[k];j--)
{
if(dp[i][j-c[k]]!=-)
dp[i][j]=max(dp[i][j],dp[i][j-c[k]]+g[k]);
if(dp[i-][j-c[k]]!=-)
dp[i][j]=max(dp[i][j],dp[i-][j-c[k]]+g[k]);
}
}
else if(s==)
{
for(j=;j<=T;j++)
dp[i][j]=dp[i-][j];
for(k=;k<m;k++)
for(j=T;j>=c[k];j--)
if(dp[i-][j-c[k]]!=-)
dp[i][j]=max(dp[i][j],dp[i-][j-c[k]]+g[k]);
}
else
{
for(j=;j<=T;j++)
dp[i][j]=dp[i-][j];
for(k=;k<m;k++)
for(j=T;j>=c[k];j--)
if(dp[i][j-c[k]]!=-)
dp[i][j]=max(dp[i][j],dp[i][j-c[k]]+g[k]);
}
}
cout<<dp[n][T]<<endl;
}
return ;
}
AreYouBusy HDU - 3535 (dp)的更多相关文章
- hdu 5534(dp)
Input The first line contains an integer T indicating the total number of test cases. Each test case ...
- HDU 5800 (DP)
Problem To My Girlfriend (HDU 5800) 题目大意 给定一个由n个元素组成的序列,和s (n<=1000,s<=1000) 求 : f (i,j,k,l, ...
- hdu 5464(dp)
题意: 给你n个数,要求选一些数(可以不选),把它们加起来,使得和恰好是p的倍数(0也是p的倍数),求方案数. - - 心好痛,又没想到动规 #include <stdio.h> #inc ...
- HDU 2571(dp)题解
命运 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...
- Find a path HDU - 5492 (dp)
Find a path Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 饭卡 HDU - 2546(dp)
电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够).所以大家 ...
- HDU 4489(DP)
http://acm.hdu.edu.cn/showproblem.php?pid=4489 解题思路这里已经说的很清楚了: http://blog.csdn.net/bossup/article/d ...
- hdu 1024(dp)
传送门:Max Sum Plus Plus 题意:从n个数中选出m段不相交的连续子段,求这个和最大. 分析:经典dp,dp[i][j][0]表示不取第i个数且前i个数分成j段达到的最优值,dp[i][ ...
- HDU 2577(DP)
题意:要求一个字符串输入,按键盘的最少次数.有Caps Lock和Shift两种转换大小写输入的方式 思路:用dpa与dpb数组分别记录Caps Lock的开关状态,dpa表示不开,dpb表示开 代码 ...
随机推荐
- CSS——三种页面引入方法
目的:为了把样式和内容分开,并且使网页元素更加丰富,引入了CSS CSS页面引入有三种方式: 1)内联式:比较不常用,因为内容和样式仍然在一起,不方便.示例: <!DOCTYPE html> ...
- linux yum 安装
################## http://rpm.pbone.net/ 下载下来的包放到本地yum源中,然后在这个目录下面重新生成依赖关系就可以使用yum包来完成安装了 tt 1. 生成依赖 ...
- SQL server下所有表名及字段名及注释查询
--查询所有表及注释SELECTA.name ,C.valueFROM sys.tables A LEFT JOIN sys.extended_properties C ON C.major_id = ...
- Vue2.0 官方文档学习笔记
VUE2.0官方文档 基础部分: 1.VUE简介 Vue是一个基于MVVM的框架,其中M代表数据处理层,V代表视图层即我们在Vue组件中的html部分,VM即M和V的结合层,处理M层相应的逻辑数据,在 ...
- css3创建多边形clip属性,可用来绘制不规则图形了
.path1 { clip-path: polygon(5px 10px, 16px 3px, 16px 17px); } .path2 { clip-path: polygon(3px 5px, 1 ...
- CentOS查找文件命令
[root@VM_147_255_centos ~]# find / -name aa.jpg 在根目录输入 如上命令,在全部目录中查找名字为aa.jpg的文件( *.jpg查找以.jpg结尾的所有文 ...
- Ubuntu获取root 权限,开机自动登入root
新机器获取root权限,只需要给root 增加密码: sudo passwd root 修改开机自动登入: #sudo gedit /etc/lightdm/lightdm.conf 修改参数: au ...
- Android 自定义Adapter中实现startActivityForResult的分析
最近几天在做文件上传的时候,想在自定义Adapter中启动activity时也返回Intent数据,于是想到了用startActivityForResult,可是用mContext怎么也调不出这个方法 ...
- 获取cell中的button在整个屏幕上的位置
编写cell中得button点击事件 - (IBAction)showButtonClick:(id)sender { UIButton *button = (UIButton *)sender; U ...
- LibreOJ #2003. 「SDOI2017」新生舞会
内存限制:256 MiB 时间限制:1500 ms 标准输入输出 题目类型:传统 评测方式:文本比较 上传者: 匿名 01分数规划(并不知道这是啥..) km或费用流(并不会)验证 屠龙宝刀点击就送 ...