Two identical masses sliding down a hill, one dips below the other one and comes back up. Which reaches the goal (at same height) faster? I am considering a situation where two identical masses are side by side and slide down a hill, ignoring friction. But one mass dips into a trench and comes back up, while the other one simply finishes rolling down the hill and continues at constant velocity. I would like to know which ball first passes a "finish line" somewhere after the trench. I drew a crude diagram to explain:

The way I tried to solve was to assume they have the same speed right before and after the trench, therefore they won't pass each other after the trench, so the one that is ahead once they both are past the trench is automatically the winner. Then I tried to figure out if the added velocity for the mass in the trench is enough to overcome the added distance for travelling in the trench. But I am stuck because I don't know how to formulate this properly mathematically. I considered a special case for the trench being a triangle (ignoring any speed loss from impacting a sharp corner) but the result I came up with is that the winner seems to depend on both the depth of the trench and the height fallen before the trench, which seems wrong to me.
My main question is how to conceptually figure out which mass will win the race? As a secondary question to show mathematically whether or not it depends on the heights, shape of the trench, etc.
 A: Assuming the crudity of your diagram to be quite large,and my understanding of it to be correct, this is the brachistochrone problem. The one that dips below will make it to the GOAL faster, provided the function of the curve is a particular cycloid in shape. I suggest you read up on variational calculus, and when you're done, read THIS.
A: The track with the dip will beat the track without. 
Consider the horizontal component of each object's acceleration. Once the object on the upper track enters the flat section, this is zero. However, the object on the lower track will continue to have an acceleration along the track, which has a forward, horizontal component, so the horizontal component of its velocity will increase above that of the object on the flat track. On its way up from the dip, its horizontal velocity will decrease but still be above that of the other object until it returns to the height of the flat track. You can see this physics demo in many places. Here is one example: https://www.youtube.com/watch?v=8XsKCBJx9DI
Note that this problem is different from the brachistochrone question and that I am resolving motion into vertical and horizontal components, not components parallel and perpendicular to the track.
