Can not able to solve JULKA problem on spoj ( Sir told in video at 1:24:51)

The code is giving runtime error.
here is my code in java