毕业bg--hdu1881(01背包)
http://acm.hdu.edu.cn/showproblem.php?pid=1881
01 背包 先按发起人离开的时间从小到大排序
然后再套01背包的模板
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 200
#define INF 0xfffffff
typedef long long ll; struct node
{
int h,l,t,k;
}a[N];
int dp[N]; int cmp(node x,node y)
{
return x.t<y.t;
}
int main()
{
int n;
while(scanf("%d",&n),n>=)
{
int Max=;
for(int i=;i<n;i++)
{
scanf("%d %d %d",&a[i].h,&a[i].l,&a[i].t);
a[i].k=a[i].t-a[i].l;
Max=max(Max,a[i].t);
}
sort(a,a+n,cmp);
memset(dp,);
int ans=;
for(int i=;i<n;i++)
{
for(int j=a[i].t;j>=a[i].l;j--)
{
dp[j]=max(dp[j],dp[j-a[i].l]+a[i].h);
ans=max(ans,dp[j]);
}
}
printf("%d\n",ans);
}
return ;
}
毕业bg--hdu1881(01背包)的更多相关文章
- HDU-1881 毕业bg (01背包变形)
毕业bg Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...
- 九度OJ 1030:毕业bg (01背包、DP)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1814 解决:798 题目描述: 每年毕业的季节都会有大量毕业生发起狂欢,好朋友们相约吃散伙饭,网络上称为"bg" ...
- UVALive 4870 Roller Coaster --01背包
题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F , D -= K 问在D小于等于一定限度的时 ...
- POJ1112 Team Them Up![二分图染色 补图 01背包]
Team Them Up! Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7608 Accepted: 2041 S ...
- Codeforces 2016 ACM Amman Collegiate Programming Contest A. Coins(动态规划/01背包变形)
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Ha ...
- 51nod1085(01背包)
题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085 题意: 中文题诶~ 思路: 01背包模板题. 用dp[ ...
- *HDU3339 最短路+01背包
In Action Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- codeforces 742D Arpa's weak amphitheater and Mehrdad's valuable Hoses ——(01背包变形)
题意:给你若干个集合,每个集合内的物品要么选任意一个,要么所有都选,求最后在背包能容纳的范围下最大的价值. 分析:对于每个并查集,从上到下滚动维护即可,其实就是一个01背包= =. 代码如下: #in ...
- POJ 3624 Charm Bracelet(01背包)
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34532 Accepted: 15301 ...
随机推荐
- Hello Shell
shell是Linux平台的瑞士军刀,能够自动化完成很多工作.要了解UNIX 系统中可用的 Shell,可以使用 cat /etc/shells 命令.使用 chsh 命令 更改为所列出的任何 She ...
- 用Vue的方式实现复选框
var borrVm = new Vue({ el: "#WingApp", data: { returnBookList:[], checked:"", ch ...
- python基础一 day9 函数升阶(2)
def max(a,b): return a if a>b else bprint(max(1, 2)) # 函数进阶# a = 1# def func():# print(a)# func() ...
- unnamed not found for the web module
intellij idea tomcat 启动报错not found for the web module 使用intellij idea 创建tomcat项目的时候会出现该错误: 启动tomcat的 ...
- Microsoft Windows Server 系统基本配置
Microsoft Windows Server 系统基本配置 环境基本配置 桌面和显示属性 更新服务器名称 更新用户密码 创建密码重置盘 设置网络类型 TCP/IP设置 ping和ipconfig命 ...
- JavaEE-09 Ajax与jQuery在JavaEE项目中的使用
学习要点 JavaScript实现Ajax jQuery实现Ajax JSON JSON-LIB FastJSON JavaScript实现Ajax 认识Ajax 旧版百度地图 百度搜索自动补全 百度 ...
- 弹跳加载动画特效Bouncing loader
一款非常常用的css 加载动画,这款CSS3 Loading动画主要由几个小球通过规律的上下跳动,渐隐渐显而成,效果十分生动.流畅.兼容IE8以上,尤其适合在移动端中使用,基本代替了图片实现加载的效果 ...
- 「 Luogu P2574 」 XOR的艺术——线段树
# 解题思路 这题不难,但是原谅我一开始的傻逼想法,一会儿再给大家透露透露. 先说怎么做这题. 显然对于 $0$ 和 $1$ 来说,异或无非也就只有两种变化 异或了奇数次,$0$ 就会变成 $1$,$ ...
- typedef重复定义 和 error: ‘long long long’ is too long for GCC
今天发现一个很有意思的编译问题,然后在Stack Overflow上也有看到类似的.就是出现了 long long long 类型错误提示 错误提示如下: /home/yejy/algorithm_a ...
- MySQL redo log 与 binlog 的区别
MySQL redo log 与 binlog 的区别 什么是redo log 什么是binlog redo log与binlog的区别 1. 什么是redo log? redo log又称重做日志文 ...