O(n) failed in java CHEFMGX problem in Starters 16

i got TLE in Contest Page | CodeChef
and the solution i used is (Solution: 52712503 | CodeChef) and in this code i have written in O(n) complexity eventhough i got TLE and i request to give Java users some more time for the solution or just evaluate the solution based on a particular predeclared function without considering IO;
Atlast i wrote the same solution in C (Solution: 52740177 | CodeChef) it got AC;