以最低质量最大化组件的质量,同时不超出预算所需的购买怎么用C语言的程序来计算解决?

Problem Description
Recently your team noticed that the computer you use to practice for programming contests is not good enough anymore. Therefore, you decide to buy a new computer.

To make the ideal computer for your needs, you decide to buy separate components and assemble the computer yourself. You need to buy exactly one of each type of component.

The problem is which components to buy. As you all know, the quality of a computer is equal to the quality of its weakest component. Therefore, you want to maximize the quality of the component with the lowest quality, while not exceeding your budget.

Input
On the first line one positive number: the number of testcases, at most 100. After that per testcase:

One line with two integers: 1 ≤ n ≤ 1 000, the number of available components and 1 ≤ b ≤ 1 000 000 000, your budget.

n lines in the following format: “type name price quality”, where type is a string with the type of the component, name is a string with the unique name of the component, price is an integer (0 ≤ price ≤ 1 000 000) which represents the price of the component and quality is an integer (0 ≤ quality ≤ 1 000 000 000) which represents the quality of the component (higher is better). The strings contain only letters, digits and underscores and have a maximal length of 20 characters.

Output
Per testcase:

One line with one integer: the maximal possible quality.

Sample Input
1
18 800
processor 3500_MHz 66 5
processor 4200_MHz 103 7
processor 5000_MHz 156 9
processor 6000_MHz 219 12
memory 1_GB 35 3
memory 2_GB 88 6
memory 4_GB 170 12
mainbord all_onboard 52 10
harddisk 250_GB 54 10
harddisk 500_FB 99 12
casing midi 36 10
monitor 17_inch 157 5
monitor 19_inch 175 7
monitor 20_inch 210 9
monitor 22_inch 293 12
mouse cordless_optical 18 12
mouse microsoft 30 9
keyboard office 4 10

Sample Output
9

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

8
javascript求数组中的最大数,返回的是数组的下标,不是值,百度了一天没找到,怎么做
5
一个难倒三线城市所有开发人员,主要在数据库方面的项目,就等给各位大侠发路费了
1
1.求c#圆形滑块demo2.c#控件用于网页,如何实现最大化
3
jdbc连接报错超出准备语句的最大数量,这是数据库超过最大连接数了么?
2
spring boot整合redis获取异常或者获取不到
1
JAVA FX 隐藏最大化,最小化按钮。只显示一张图片。
2
输入一个整数n再输入一个n行n列的矩阵,找出该矩阵中绝对值最大的元素以及它的行号列号
1
WPF窗体最大化后如何从A显示器拖动到另外一个显示器?
0
运用C语言的知识编程,收益只能通过购买这些理财产品获得。求小A可以获得的最大收益
1
深度学习做回归问题如何对数据集进行标准化,归一化?
2
js能否控制ie在最小化时有消息提醒时最大化,或者图标闪烁
3
Delaunay三角网的空圆特性和最大化最小角特性是需要同时满足吗?
1
运用C语言程序计算的问题:比赛的得分只有x分和y分两种形式,最大的不可以得到的分数是多少
3
ThreadPoolTaskExecutor 异步任务 对于长时间大数据的执行,执行一半线程终止。
4
使用free -m命令,发现free状态的内存比available内存要大,应用程序无法全部申请free内存
3
springboot内置tomcat,网上说最大线程连接数是200,可我的为什么是0??
1
WebDriver driver = new ChromeDriver();报错
0
放置起重机以最大化所有起重机所覆盖的总面积的计算,怎么用C语言的程序的代码编写的技术有效实现的过程
0
建造一座塔楼并最大化塔楼的高度使用的积木的计算,怎么采用C语言的代码的编写的过程来实现的呢
0
足球队选球员如何选择11个人来使总价值最大化,怎么使用C语言的程序的设计的办法来解决的