A theater has n seats, indexed 1..n, all starting with 0 check-ins. Over the course of an event, m check-in scans occur; each scan l r marks one additional check-in for every seat in the inclusive range [l, r] (a seat may be marked by several different scans). After all m scans, given a threshold T, count how many seats ended up with a check-in count >= T.
Line 1: three integers n m T.
Next m lines: two integers l r each.
A single integer: the number of seats whose final check-in count is >= T.
Example 1
Input
5 3 2 1 3 2 5 3 3
Expected
2
Explanation
Check-in counts end up [1,2,3,1,1]. Seats 2 and 3 (counts 2 and 3) meet the threshold of 2, giving a count of 2.
Example 2
Input
3 0 0
Expected
3
Explanation
No scans occur, so every seat has 0 check-ins, and the threshold is 0, so all 3 seats qualify.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →