Platform Jumper
In an old school arcade video game, you have reached the following bonus level. There are a number of platforms containing coins, and you must jump from platform to platform collecting the coins. You may only jump to lower platforms, so your entire journey will be downward. You can select any platform as your starting platform.
Your jumping behavior is defined as follows. On each jump, your horizontal speed is constant and does not exceed v. Your fall down follows the standard laws of physics: your free fall acceleration is g and initially your speed is 0.
For simplicity, we will represent each platform as a single point. Each element of platforms represents a single platform and is formatted "X Y C" (quotes for clarity), where X and Y are the x and y coordinates of the platform and C is the number of coins on the platform. Greater values of y represent higher locations. Find the greatest number of coins you can collect.
Input
Consists of multiple test cases. The first line of each test case contains three integers: the number of platforms n (1 ≤ n ≤ 50), and the values of v and g (1 ≤ g, v ≤ 100). Next n lines describe the platforms in "X Y C" format. Is is known that 0 ≤ X, Y ≤ 5000, 0 ≤ C ≤ 10000.
Output
For each test case print in a separate line the greatest number of coins you can collect.