ZCO 2014 IPL problem WA

I am participating in zco 2015 and wanted to solve previously asked problems and got stuck on this problem. the problem is my code works for the first three inputs but fails on the remaining. My logic is as follows:
if the guy has played jth game and not (j-1)th game, he chooses the max from j+1 or j+2(skipping j+1 game).
else he chooses j+2th game and continues.
can anybody tell me what might be wrong in this!?
this is the link to problem statement:

Okay here’s the solution: