Hey there,

Problem

My Solution

I wrote a solution which uses priority queue and pops the maximum element until the sum of elements inside the priority queue is greater than (m-ti) for all 1<=i<=n, so the running time (according to me) is n*logn*max(ti) as at every pop operation the sum will reduce by atleast 1 (1<=ti<=100), logn for priority queue operations and total of n students.

When I submitted the code, it gave me TLE on test #14.

Any help is appreciated.

Thank You.