In output shows the TLE

code:: https://ide.codingblocks.com/s/244324
ques:: https://hack.codingblocks.com/app/contests/1289/158/problem

plz bhaiya solve my problem

@Kamal_it the problem is giving TLE on simply taking input (also on using fastIO)!!
I saw your code and there is logical error, you are swapping queried element with last one and pop it out, this deletes the element but order is now distorted!
Also in constraints k<=1000 so we can just update elements from start on every query,
this makes runtime complexity as in order of(10^7) as each query may take in order of 10^3 and there are 10^4 queries. So this should be acceptable.

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.