Problem X
went to an ancient country. For such a long time, it was the most
wealthy and powerful kingdom in the world. As a result, the people
in this country are still very proud even if their nation hasn’t
been so wealthy any more.
The merchants were the most typical, each of them only sold exactly
one item, the price was Pi, but they would refuse to make a trade
with you if your money were less than Qi, and iSea evaluated every
item a value Vi.
If he had M units of money, what’s the maximum value iSea could
get?
several test cases in the input.
Each test case begin with two integers N, M (1 ≤ N ≤ 500, 1 ≤ M ≤
5000), indicating the items’ number and the initial money.
Then N lines follow, each line contains three numbers Pi, Qi and Vi
(1 ≤ Pi ≤ Qi ≤ 100, 1 ≤ Vi ≤ 1000), their meaning is in the
description.
The input terminates by end of file marker.
case, output one integer, indicating maximum value iSea could
get.
10
5
5
#include
#include
#include
#include
#define maxn 5050
using namespace std;
struct node
{
int
p,q,v;
bool
operator < (const node & other) const
{
return this->q-this->p
}
};
int main()
{
//freopen("in.txt", "r", stdin);
int
n,m;
while(~scanf("%d%d",&n,&m))
{
int dp[maxn]={0};
node nod[maxn];
for(int i=0;i
scanf("%d%d%d",&nod[i].p,&nod[i].q,&nod[i].v);
sort(nod,nod+n);
for(int i=0;i
for(int j=m;j>=nod[i].p;j--)
{
if(j>=nod[i].q)
dp[j]=max(dp[j],dp[j-nod[i].p]+nod[i].v);
}
printf("%d\n",dp[m]);
}
return
0;
}
Problem X的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- linux文件权限解析(摘)
用户组 在linux中的每个用户必须属于一个组,不能独立于组外.在linux中每个文件有所有者.所在组.其它组的概念 - 所有者 - 所在组 - 其它组 - 改变用户所在的组 所有者 一般为文件的创建 ...
- 【ASP.NET MVC】jqGrid 增删改查详解
1 概述 本篇文章主要是关于JqGrid的,主要功能包括使用JqGrid增删查改,导入导出,废话不多说,直接进入正题. 2 Demo相关 2.1 Demo展示 第一部分 第二部分 2.2 ...
- 跨平台移动端APP开发---简单高效的MUI框架
MUI是dcloud(数字天堂)公司旗下的一款跨平台开发移动APP的框架产品,在学习MUI框架之前,最先接触了Hbuilder代码编辑器,它带给我的第一感觉是快,这是HBuilder的最大优势,通过完 ...
- python之串口操作
1.安装pyserial linux上直接安装: #python2 sudo pip install pyserial #或者python3 sudo pip3 install pyserial Wi ...
- ZOJ2724 Windows Message Queue 裸queue的模拟
题目要求FIFO #include<cstdio> #include<cstdlib> #include<iostream> #include<queue&g ...
- 从实践的角度理解cookie的几个属性
cookie的处理流程大致分为以下几步: 1.浏览器初次请求服务器. 2.服务器认为有必要设置cookie,通过响应报文首部:Set-Cookie告知浏览器,cookie的内容. 3.浏览器本地保存( ...
- Scrapy框架--Requests对象
Scrapy使用request对象来爬取web站点. request对象由spiders对象产生,经由Scheduler传送到Downloader,Downloader执行request并返回resp ...
- Appium python自动化测试系列之Android知识讲解(三)
3.1 ADB工具讲解 3.1.1 什么是ADB呢? 我们不去解释官方语言的翻译,给大家说一个通熟易懂的说法,ADB我理解为他就是电脑和手机连接的桥梁.此连接不是充电的连接,大家不要混淆,说他是一个 ...
- 关于AOP装饰函数中的this
在学习关于JavaScript的装饰者设计模式的过程中,发现其实现方式的关键在于this的使用. 想象一个匿名函数(其实预定义的有名函数也可以,都存在引用),其中的this: // 我们先定义一个匿名 ...
- win10 uwp 获取指定的文件 AQS
很多时候不需要获取整个文件夹的文件,是需要获取文件夹里指定的文件. 那么 UWP 如何对文件夹里的文件进行过滤,只拿出自己需要的文件? 本文:如何使用通配符或文件匹配方式在uwp获取文件夹中指定的文件 ...