What is the error?

error: runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15

Hey @ashish_arora369, you are getting this because you are initialising an array which is of very large size. Instead of such big number of 10 raise to power make it of int *arr=new int[n] after taking input n. Rest your logic is correct as I have run it on ide.codingblocks.com

Output terminate called after throwing an instance of ‘std::bad_alloc’ what(): std::bad_alloc /bin/run.sh: line 4: 18 Aborted (core dumped) ./exe


Might be some issue in your ide , you can use coding blocks online ide.

i’m using coding block online ide. in that it is showing me this

But you can see I am also using the same and it’s giving me legit output. Try after some time, might be some back end issue.