
101  ZOJ Monthly, December 2010  E
Doraemon's city is being attacked again. This time Doraemon has built a powerful railgun in the city. So he will use it to attack enemy outside the city. There are N groups of enemy. Now each group is staying outside of the city. Group i is located at different (X_{i}, Y_{i}) and contains W_{i} soldiers. After T_{0} days, all the enemy will begin to attack the city. Before it, the railgun can fire artillery shells to them. The railgun is located at (X_{0}, Y_{0}), which can fire one group at one time, The artillery shell will fly straightly to the enemy. But in case there are several groups in a straight line, the railgun can only eliminate the nearest one first if Doraemon wants to attack further one. It took T_{i} days to eliminate group i. Now please calculate the maximum number of soldiers it can eliminate. InputThere are multiple cases. At the first line of each case, there will be four integers, X_{0}, Y_{0}, N, T_{0} (1000000000 ≤ X_{0}, Y_{0} ≤ 1000000000; 1 ≤ N ≤ 500; 1 ≤ T_{0} ≤ 10000). Next N lines follow, each line contains four integers, X_{i}, Y_{i}, T_{i}, W_{i} (1000000000 ≤ X_{i}, Y_{i} ≤ 1000000000; 0 ≤ T_{i}, W_{i} ≤ 10000). OutputFor each case, output one integer, which is the maximum number of soldiers the railgun can eliminate. Sample Input0 0 5 10 0 5 2 3 0 10 2 8 3 2 4 6 6 7 3 9 4 4 10 2 Sample Output20 Author: XU, Shicheng; (data: WU, Zejun) Contest: ZOJ Monthly, December 2010 