getting wrong answer in chef and chain (FEB15)

although i think my code giving answer correctly when compiled on other environment its giving wrong answer on submtting here.

Most probably your logic may be wrong or there may be initialization problem. Try to check your code with some inputs Here : Compile and run the code with online compiler and IDE | CodeChef

same problem