The motion along the y-axis is absolutely *not* irrelevant. You are right to feel bad about that answer!

Assuming the balls stay attached to the ground underneath them, the second ball has to do two things differently from the first:

 - Travel the distance up and down while changing speed, and
 - Cross the valley gap faster than otherwise.

The ball with the complex motion will only beat the simple one if the gains crossing the gap at speed overpower the losses traveling the extra distance up and down. Think about the limit as the width of the gap goes to zero - if the complex-motion ball just stops in the middle to travel up and down there's no way it could beat the first.

I would suggest treating the problem as if the pit's sides were vertical and the ball was on a track that attached it to the edges. You will find that the answer depends on the depth and width of the pit.