This problem is pretty straight forward. All you need to do is to check at each time starting from 1 continuously if there are some employees who have already spent more than or equal to t. To be more clear, we just propagate through time from 1. Then we can have a meeting for every k employees among them. But, if there are multiple combinations to do that, we need to select employees whose working period will end sooner so that the rest of the available employees may have a meeting later.

To keep track how many employees are working currently at a particular time, we can have a segment tree or we can use PBDS. we just need to update the segment tree for the starting and ending time of employees’ working period and query for each particular time. We may also need a set or multiset to keep track of which employees had a meeting already or whose working period ended.

Time Complexity: O(Tmax+n)logmax(Tmax, n)), where Tmax means maximum of the ending times of all employees.


61% Solution Ratio
YouKnowWhoEarliest, Mar '20
nusuBotFastest, 0.0s
Fizzz_83Lightest, 1.6 MB
al.nomanShortest, 711B
Toph uses cookies. By continuing you agree to our Cookie Policy.