May be I know what is your problem now.
The potential energy U(y)=mgy  does not have a maximum value along y direction.
But, it is the particle which has maximum potential energy when it reach the highest point.

It is due to total energy of the particle is conserved: kinetic energy + potential energy = (1/2)mv[sup]2[/sup]+mgh=total energy , which is a constant.