I tried many times this question but getting WA for higher test cases.
Since i did it with by two ways.
(1) Firstly i create a priority queue using STL(which is max heap by default) and then start loop for days 1 to D, and at the beginning of each i’th day, I put all the members who are coming on i’th day into queue and if queue is empty(in case of no trainers are available for those days) then do nothing. but if queue is not empty then then pop from queue and decrease its demand by 1 and if demand is still not zero then push it again into queue. and at last(after camp gets completed) all the elements that left in queue will give the answer
I tried it many times but getting AC only for small data sets. You can check my solution here
(2) After getting too many WA i did it using heap(std stl heap) with same approach as above.
But only time running time gets reduced, as still getting WA for higher data sets. You can see my second solution here.
Now Please tell me what’s wrong in my code…
Thanks in advance.