### National Olympiad in Informatics, China, 2010

## Day 2, Problem 3 - Happily Growing

Nemo is a carefree little fish. His initial birth weight is `w`_{0}. 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 `n` shrimps in the ocean, numbered from 1 to `n`. Shrimp `i` will have a weight of `w _{i}`. The ocean can be represented as a Cartesian plane. At time 0, shrimp

`i`will be at position (

`x`,

_{i}`y`). In the ocean, shrimps move in straight lines at constant velocities. Shrimp

_{i}`i`'s velocity vector is (

`p`,

_{i}`q`), which means at time

_{i}`i`, its position will be (

`x`+

_{i}`p`*

_{i}`t`,

`y`+

_{i}`q`*

_{i}`t`).

At time 0, Nemo's position will be (`x`_{0}, `y`_{0}). He may move however he pleases in the ocean, but his speed cannot exceed `V`. Through his own hard work, Nemo wishes to eat the largest weight of shrimp as possible within `T` units of time (containing `T` 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 `w _{i}`, his own weight will increase by

`w`. Note: shrimps cannot eat Nemo, nor will they cannibalize each other.

_{i}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 Format

There are 10 test cases `nemo1.in`

~ `nemo10.in`

that will be given to your program (through standard input). They can be downloaded here for you to study: nemo.zip

Line 1 of input contains an integer from 1 to 10, representing the test case number. Test case `nemo`

will have `i`.in`i` on its first line.

Line 2 contains five real numbers `w`_{0}, `V`, `T`, `x`_{0}, and `y`_{0}. Respectively, the represent Nemo's initial weight, maximum speed, time to eat shrimp, and initial position at time 0.

Line 3 contains a single integer `n`, representing the number of shrimp there are in the ocean.

For the following `n` lines, each line contains 5 real numbers `w _{i}`,

`x`,

_{i}`y`,

_{i}`p`, and

_{i}`q`, representing the weight of shrimp

_{i}`i`, its position at time 0, and its velocity vector.

### Output Format

Line 1 of output should consists a single integer `k`, representing the number of shrimps Nemo will eat in your plan.

Line 2 should consists of a single real number `w`, representing the total weight of shrimps that Nemo will eat in your plan.

For the following `k` lines, each line should contain 4 numbers `t`, `x`, `y`, and `s`. This indicates that at time `t`, Nemo should be at position (`x`, `y`) to eat shrimp `s`. Here, `t`, `x`, and `y` are real numbers, while `s` is an integer.

To ensure that your answer is precise enough, we suggest outputting all real numbers to 6 digits after the decimal. During grading, two real numbers are considered equivalent if their error (i.e. absolute difference) does not exceed 10^{−4}.

### 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 5, Nemo will be at position (2, 2) to eat shrimp number 1. Nemo can actually reach (2, 2) much earlier, since the problem only requires his speed to merely not exceed `V`.

### Scoring

For each test case, we will have 9 grading parameters `a`_{10}, `a`_{9}, …, `a`_{2}. If your output is invalid, then you will be given a score of 0. Otherwise, assuming that Nemo's weight increase in your solution is `w`_{user}, then your score out of 10 for the test case will be determined as follows:

Score | Condition |
---|---|

10 | w_{user} ≥ a_{10} |

9 | w_{user} ≥ a_{9} |

8 | w_{user} ≥ a_{8} |

7 | w_{user} ≥ a_{7} |

6 | w_{user} ≥ a_{6} |

5 | w_{user} ≥ a_{5} |

4 | w_{user} ≥ a_{4} |

3 | w_{user} ≥ a_{3} |

2 | w_{user} ≥ a_{2} |

1 | w_{user} > 0 |

If multiple conditions are satisfied, then the condition that yields the highest score will be taken.

All Submissions

Best Solutions

**Point Value:** 50 (partial)

**Time Limit:** 60.00s

**Memory Limit:** 512M

**Added:** Aug 08, 2014

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

It's quiet in here...