12124-assemble
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_ problem&problem=3276
Recently your team noticed this computer you with to practice for programming contests are not good enough anymore. Therefore, you are decide to buy a new computer.
To make the ideal computer for your needs, you decide to buy separate components and assemble the computer. You are need to buy exactly one of each type of component.
The problem is which components. As you are all know, the quality of a computer was 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.
Input
On the ' I ' one positive number:the number of testcases, at most 100. After this per TestCase:
One line with two integers:1≤n≤1000, the number of available components and 1≤b≤1000000000, your budget.
N lines in the following format: ' Type name price quality ', Wheretype are a string with the type of the component, name I s a string with the unique name of the Component,price was an integer (0≤price < 1000000) which represents the price O F The component andquality is an integer (0≤quality≤1000000000) which represents the quality of the component (higher is better). The strings contain only letters, digits and underscores and have a maximal length.
It would always possible to construct a computer with your budget.
Output
Per TestCase:
One line with one integer:the maximal possible quality.
Sample Input
1
processor 3500_mhz 5
processor 4200_mhz 7
processor 5000_mhz 156 9
Processor 6000_mhz 219
Memory 1_GB 3
memory 2_GB 6
memory 4_GB 170
mainbord all_onboard harddisk GB
harddisk 500_fb
casing MIDI
Monitor 17_inch 157 5
Monitor 19_inch 175 7
Moni Tor 20_inch 210 9
Monitor 22_inch 293 mouse cordless_optical
Mouse Microsoft 9
keyboard Fice 4 10
Sample Output
9
Idea: The most common way to solve the "minimum value" is a two-point answer. If the answer is x, then delete all the accessories that are less than x, and if you can assemble a computer, the correct answer is ans>=x or ans<x.