Why Spoj is giving issue for "JAVA"

I came to spoj to practice questions on segment tree, first I solved “SEGSQRSS” got TLE, struggle and ask many good coders, everyone is saying the solution https://ideone.com/xsxZSw is perfect and good. Then I tried another problem “GSS1” same issue TLE https://ideone.com/JE4pQL. Then I translate the accepted solution of C++ into java then also same issue.

Why for java solution there is TLE. Everywhere my segment tree Java solution successfully submitter on Hackerearth, Codechef, etc. but not in spoj.

i also face this type of issue with spoj but I don’t no why,maybe time limits are to tight for java programmers