#P1915. Nemo's Growth Plan
Nemo's Growth Plan
Nemo's Growth Plan
Nemo is a carefree little fish whose initial weight is (w_0). To grow as fast as possible, Nemo wants to eat as many shrimps as he can within (T) time units (including time (T)). There are (n) shrimps in the sea, numbered from 1 to (n). The (i)th shrimp has a weight (w_i), and at time (0) it is located at ((x_i, y_i)). Each shrimp moves in a straight line at constant velocity ((p_i, q_i)); that is, at time (t) its position is ((x_i+p_i,t,; y_i+q_i,t)).
At time (0), Nemo is at ((x_0,y_0)) with weight (w_0) and can move anywhere in the sea, but his speed cannot exceed (V). Nemo can eat a shrimp if at the same moment they are at the same position and the shrimp's weight is strictly less than Nemo's current weight. After eating a shrimp with weight (w_i), Nemo's weight increases by (w_i). Note that shrimps do not eat each other nor Nemo.
Your task is to help Nemo devise a plan so that he can maximize the total weight of shrimps eaten within (T) time units. For planning purposes, assume that Nemo may only intercept a shrimp at an integer time moment. In other words, if Nemo, starting from a position ((X,Y)) at time (t) with weight (W), intends to eat a shrimp (i) (with (W > w_i)), he needs to choose an integer time (t') (with (t'\ge t) and (t'\le T)) such that the shrimp's position at time (t') is ((x_i+p_i,t',; y_i+q_i,t')) and the travel distance from ((X,Y)) to ((x_i+p_i,t',; y_i+q_i,t')) is at most (V,(t'-t)). After this, Nemo's weight increases by (w_i) and his new position becomes ((x_i+p_i,t',; y_i+q_i,t')).
Determine the maximum total weight of shrimps that Nemo can eat within the time limit (T).
inputFormat
The first line contains six numbers: n T V w0 x0 y0
, where
n
is the number of shrimps,T
is the total available time (an integer),V
is Nemo's maximum speed,w0
is Nemo's initial weight,x0
andy0
are Nemo's initial coordinates.
Then follow n
lines, each describing a shrimp. The i
th line contains five numbers: w_i x_i y_i p_i q_i
, representing the weight, initial coordinates, and velocity vector components of the shrimp.
outputFormat
Print a single number which is the maximum total weight of shrimps that Nemo can eat within time \(T\).
sample
2 10 1 5 0 0
3 1 0 0 0
7 10 0 0 0
10