Here are IOITC 2016 problems uploaded by Agnishom Chattopadhyay.

Active In

Indian Computing Olympiad (ICO)

Competitive Programming

Featured Contributions

comment in this discussion

comment in this discussion

Aditya Dutt32w

I did almost the exact same thing. Complexity is \mathcal{O}(n\log{}n) because Inserting and Erasing in a set takes \mathcal{O}(\log{n}) operation and we are inserting and erasing elements \mathcal{O}(n) times.

I was looking for Data Structures that would work for this question and realized Priority Queue wouldn't work because it only allows deleting from the top of the queue and Set wouldn't work because it only stores Unique Keys.

Be careful not to do:

mltist.erase(key)

because it deletes all the matching keys rather than just one. You need to do:

mltist.erase(mltist.find(key))

which remove sonly a single matching key.

Read more… (95 words)