See you have to optimize your code a lot and have to use faster IO templates in JAVA for strict timelimit problems because JAVA is a slower language as compared to C/C++.
It takes much time in IO process.
Even i have faced such problems. Here it is.
JAVA solution : - https://www.codechef.com/viewsolution/8884493 (got TLE)
C solution : - https://www.codechef.com/viewsolution/8884719 (got accepted)
Better idea would be - you may go for C,C++ for such problems.
Happy coding. :)

See you have to optimize your code a lot and have to use faster IO templates in JAVA for strict timelimit problems because JAVA is a slower language as compared to C/C++.
It takes much time in IO process.
Better idea would be - you may go for C,C++ for such problems.
Happy coding. :)