|
||||||||||
Rocket StagesTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 290 Accepted Submission(s): 66 Problem Description Many rockets are made up of several stages to increase efficiency. When the fuel in one stage burns up, the stage can be discarded, reducing the weight of the remaining rocket. The first stage needs a strong engine capable of lifting the whole rocket, while later stages can have smaller engines. In this problem, you will determine which stages to put together to maximize the upward velocity of the rocket when all the fuel has burned. For each stage, you will be given:
Due to safety regulations, the net acceleration of the rocket is never allowed to be downwards, until the rocket runs out of fuel. Also due to safety regulations, the total mass of the rocket cannot exceed 10000 kilograms. The rocket must have at least one stage. Input The first line of input contains one integer specifying the number of test cases to follow. Each test case begins with a line containing an integer N, the number of rocket stages in the current test case. There will be no more than 1000 stages. This line is followed by N lines, one for each stage. Each of these lines contains the four integers S, L, T, C that describe a stage, as explained above. Each of these integers can be represented by a 32-bit unsigned binary number. The order of the stages as listed must be preserved but some stages (including, possibly, the first stage) may be left out of the rocket. The stage listed first is at the top of the rocket (and will burn last). For every test case in the input, it is always possible to construct at least one rocket satisfying all the requirements of the problem statement. Output For each test case, output a line containing a single integer, the maximum possible speed in metres per second of the rocket when it has finished burning, rounded to the nearest metre per second. Sample Input
Sample Output
Source | ||||||||||
|