For this question on codeforces, where the intended solution is using segment tree, I found some naive solution which are getting accepted.
Can someone explain me how these codes are passing all the test cases and what is the optimisation used here?
For this question on codeforces, where the intended solution is using segment tree, I found some naive solution which are getting accepted.
Can someone explain me how these codes are passing all the test cases and what is the optimisation used here?
The solutions are passing because the timelimit/tesetcases are not strict enough. The only trick in these brute force solutions is to use integers inistead of long long for accumulating (possibly a time win of 50%). Only when the integer might overflow a long long is used to store the complete sum.
so, processing on integer data type is faster than Long Long data type, and we are processing on long long data type only when it is needed?