On submitting solution on SPOJ got TLE

https://codeshare.io/5PRmBP
My code, it is same as code in lecture. Still got TLE. Plz help.

@anuj_it
Please don’t worry about TLE on SPOJ if it works on CB.
There constraints are unnecessarily tight and might give TLE for time exceeded by even milli seconds.
I checked your code and everything there is as optimised as it should be.

If your doubt is resolved please close it.

@Aarnav-Jindal-1059677350830863
Ok.
Still is there any way to overcome TLE, in general, not specific to this question ?

@anuj_it
Use fast IO
Use global arrays instead of local ones
Use reference variables for arrays vectors etc
If you know size then use array not push back

If your doubt is resolved please close it

@Aarnav-Jindal-1059677350830863
I use Python3 not C++. If I’m not wrong reference variables and vectors are not in python.

If you could reply wrt Python, it would be helpful !

@anuj_it
I code in C++ only
Sorry I cant be of any help in that case

@Aarnav-Jindal-1059677350830863
Oh, you need not be. Still thanks for helping !!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.