eolymp
bolt
Try our new interface for solving problems
Problems

Platform Jumper

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 \textbf{v}. Your fall down follows the standard laws of physics: your free fall acceleration is \textbf{g} and initially your speed is \textbf{0}. For simplicity, we will represent each platform as a single point. Each element of platforms represents a single platform and is formatted "\textbf{X Y C}" (quotes for clarity), where \textbf{X} and \textbf{Y} are the \textbf{x }and \textbf{y} coordinates of the platform and \textbf{C} is the number of coins on the platform. Greater values of \textbf{y} represent higher locations. Find the greatest number of coins you can collect. \InputFile Consists of multiple test cases. The first line of each test case contains three integers: the number of platforms \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{50}), and the values of \textbf{v} and \textbf{g} (\textbf{1} ≤ \textbf{g}, \textbf{v} ≤ \textbf{100}). Next \textbf{n} lines describe the platforms in "\textbf{X Y C}" format. Is is known that \textbf{0} ≤ \textbf{X}, \textbf{Y} ≤ \textbf{5000}, \textbf{0} ≤ \textbf{C} ≤ \textbf{10000}. \OutputFile For each test case print in a separate line the greatest number of coins you can collect.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2 10
3 10 7
5 15 7
8 9 12
3 1 2
0 0 1
2 4 1
4 0 1
Output example #1
14
2