C vs C++ for XRQRS

I submitted a solution for XRQRS in C which showed TLE in last test case of first subtask:


and the same problem when submitted in C++ gave me AC:


Maybe it is because of the difference between the complexities of qsort and sort library functions in c and c++, but I am not sure. Can someone explain this?

Same happened with me :p!

More than the difference between complexities of qsort and sort, cpp might have higher time limit by some factor than C

Performance of qsort vs std::sort C & C++

Same happened with me…resulted in 7 TLE’s…

C compiler=>You will get benefit in terms of memory complexity.

C++ compiler=>Because of the implementations in algorithm header file You will get benefit in terms of time complexity.