hello , i am getting wa for my code of the problem round robin scheduling , I have tried many test case I couldn't come up with a test case where my code fails.
MY APPROACH :- i have made an observation that for each task Ti it will become zero only at an iteration equal to Ti . For example, suppose Ti = 9 then this element will become zero at the 9th iteration irrespective of all the other tasks . So i thought that i need to just sort the array based on the value of Ti and then the smallest value Ti will be the one going 1st and then all the Ti's whose values are greater than it . So , i kept two values in the vector , first :- value of Ti , and second :- index of particular Ti . Now i sorted the vector , if values of some element a and b are equal then i sort them in increasing order of index. I also maintained a binary indexed tree denoted by bit[] , this is used to tell me how many total tasks are still present before a particular element.
MY SOLUTION( i have commented each and every part ) :- link