wrong answer for a subtask

for the given problem there are two tasks
for the first task, the judge accepted the solution
for the second task,it says wrong answer …the time consumed is also well within the limits
could someone please explain how does this occur?
or what modification should i do to my solution??