Getting TLE in Java

Help needed please tell me how to optimize this code …
i am trying to solve this problem but this is not even passing the sample test case where i am doing wrong … please help

problem link – https://codeforces.com/contest/628/problem/D