Just started doing basic questions on Hacker Earth and got TLE after solution, tried everything I knew about fast I/O. Can anyone help me out?

My code:

Just started doing basic questions on Hacker Earth and got TLE after solution, tried everything I knew about fast I/O. Can anyone help me out?

My code:

Optimise your Code, not IO. You might want to use Prefix Sum.

1 Like

You have to create a prefix sum array and then compute the mean of the numbers. As the constraints for the number of queries is 10^6.

And your code has a complexity of O(n^2). So this is not going to work.

Edit: I’ve tried to solve it check it here

1 Like

I’ll do that, thankyou

Okayy, thankyou