National Olympiad in Informatics, China, 2010
Nemo is a carefree little fish. His initial birth weight is . Cute little Nemo wishes to grow up as fast as possible, and thus will need to eat as much food as possible. Nemo's favorite food is little shrimps from the ocean.
Nemo's understanding of the available food is as follows: There are a total of shrimps in the ocean, numbered from to . Shrimp will have a weight of . The ocean can be represented as a Cartesian plane. At time , shrimp will be at position . In the ocean, shrimps move in straight lines at constant velocities. Shrimp 's velocity vector is , which means at time , its position will be .
At time , Nemo's position will be . He may move however he pleases in the ocean, but his speed cannot exceed . Through his own hard work, Nemo wishes to eat the largest weight of shrimp as possible within units of time (containing moments). When Nemo and a little shrimp moves onto the same position at the same time, and the weight of the shrimp is smaller than Nemo's weight at that time, then Nemo will be able to successfully eat up the shrimp. When Nemo eats a shrimp of weight , his own weight will increase by . Note: shrimps cannot eat Nemo, nor will they cannibalize each other.
Nemo wishes for you to help him design a growth plan, so that the weight of the shrimp he eats is as large as possible.
Input Specification
There are test cases nemo1.in
to nemo10.in
that will be given to
your program (through standard input). They can be downloaded here for
you to study:
nemo.zip
Line of input contains an integer from to , representing the test
case number. Test case nemoi.in
will have on its first line.
Line contains five real numbers , , , , and
. Respectively, they represent Nemo's initial weight, maximum
speed, time to eat shrimp, and initial position at time .
Line contains a single integer , representing the number of shrimp
there are in the ocean.
For the following lines, each line contains real numbers ,
, , , and , representing the weight of
shrimp , its position at time , and its velocity vector.
Output Specification
Line of output should consist of a single integer , representing the
number of shrimps Nemo will eat in your plan.
Line should consist of a single real number , representing the
total weight of shrimps that Nemo will eat in your plan.
For the following lines, each line should contain numbers ,
, , and . This indicates that at time , Nemo should be at
position to eat shrimp . Here, , , and are real
numbers, while is an integer.
To ensure that your answer is precise enough, we suggest outputting all
real numbers to digits after the decimal. During grading, two real
numbers are considered equivalent if their error (i.e. absolute
difference) does not exceed .
Sample Input
0
6 1 6 0 0
1
5 2 2 0 0
Sample Output
1
5
5 2 2 1
Explanation
In the sample solution at time , Nemo will be at position to eat shrimp number . Nemo can actually reach much earlier, since the problem only requires his speed to merely not exceed .
Scoring
For each test case, we will have grading parameters . If your output is invalid, then you will be given a score of . Otherwise, assuming that Nemo's weight increase in your solution is , then your score out of for the test case will be determined as follows:
Score | Condition |
---|---|
If multiple conditions are satisfied, then the condition that yields the highest score will be taken.
Problem translated to English by .
Comments