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.
Hello @shuvro97…
I seen your code. but didn’t understand what you did at a glance. So it’s my advise to you please specify what’s approach you applied to design your solution. A explain in short what actually you did.
Because nobody has time to see your code and then find what approach you applied and then check where you did the mistake.
So please always put your approach in short with question…
I am always here for your help.
Also, if you can ask a question, as it as a question, and not in form of “answer” inside a question. If you ask it as a question, at least it will stay on front page and get views. It slipped my mind that i had to take a look at your code, and there was no way to remind myself of it except seeing this question (which i most probably wont as its answered already)