i am getting the second subtask incorrect while the first one is correct in a problem.why?

http://www.codechef.com/viewsolution/5788263
^link of problem summary

You are not allowed to ask for hints here.
Check the question constraints and subtask 2. Make up some handwritten test cases and verify your output.