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表示开 代码 ...
随机推荐
- 2017 ACM Arabella Collegiate Programming Contest div2的题,部分题目写个题解
F. Monkeying Around 维护点在多少个线段上 http://codeforces.com/gym/101350/problem/F 题意:有m个笑话,每个笑话的区间是[L, R], ...
- 关于小米手机USB传输稍大点的文件老中断的问题解决方法!
关于小米手机USB传输稍大点的文件老中断的问题解决方法! 这是一个很痛苦的事情,当你传输大文件的时候,传输到一半就会莫名其妙的中断,拔插数据线很多次以后,好不容易没准可以成功传输一次. 后来使用了36 ...
- MVC FileResult
你如何将文件传送给用户取决于你最开始如何存储它,如果你将文件存入数据库,你会用流的方式将文件返还给用户,如果你将文件存在硬盘中,你只需要提供一个超链接即可,或者也可以以流的方式.每当你需要以流的方式将 ...
- IQueryable和IEnumerable的区别
- Kendo MVVM 数据绑定(七) Invisible/Visible
Kendo MVVM 数据绑定(七) Invisible/Visible Invisible/Visible 绑定可以根据 ViewModel 的某个属性来显示/隐藏 DOM 元素.例如: <d ...
- Properties-转换流-打印流-序列化和反序列化-Commons-IO工具类
一.Properties 类(java.util) 概述:Properties 是一个双列集合;Properties 属于map的特殊的孙子类;Properties 类没有泛型,propert ...
- 如何删除 CentOS 6 更新后产生的多余的内核?
第一种方法:通过命令的方式解决多余的内核 1.首先查看当前内核的版本号: [root@jxatei ~]# uname -a Linux jxatei.server2.6.32-573.1.1.el ...
- vue搭建骨架屏步骤配置
1.什么是骨架屏幕? 在页面加载数据之前,有一段空白时间,要么用loading加载,要么就用骨架屏. 在开发webapp的时候总是会受到首屏加载时间过长的影响,主流的解决方法是在载入完成之前显示loa ...
- jsoup获取网页属性
package com.open1111.jsoup; import org.apache.http.HttpEntity;import org.apache.http.client.methods. ...
- 使用Java connector消费ABAP系统的函数
Java Connector(JCO)环境的搭建:Step by step to download and configure JCO in your laptop 我的ABAP系统有个函数名叫ZDI ...