Getting wrong answer while submitting answer for PSHOT problem

The code works fine for the sample input. Can anyone point out for what inputs it might fail? Here is the problem
and this is my solution. Any advise would be much appreciated.