You are competing in ski slalom, and you need to select an optimal path for the race to maximize the number of gates you can pass through.
There are N gates in total, and the gates can be considered as points. If you pass the left or the right of one gate, this gate should not be considered as a gate that you passed through. The ith gate occurs at distance yi down the hill, with the horizontal position of the ith gate given by xi. Each gate is further down the hill than the previous gate (i.e. yi < yi+1 for all i).
Your pairs of skis has speed vd (i.e. you move with a constant downward velocity of vd meters per second). Additionally, at any time you may move at a horizontal speed of at most vh meters per second.
You may start and finish at any two positions. Your task now is to calculate how many gates at most that you can pass through.