
A city festival has N food stalls. Each stall is defined by a start time, an end time, and a vendor type ('local' or 'guest'). A stall is considered "operating" at any time t if starttime <= t < endtime.
The city planner needs to allocate resources by determining the peak demand for each vendor type. Your task is to find two values:
The first line of input contains an integer N, the number of stalls.
The next N lines each contain two integers, start and end, and a string type ("local" or "guest"), separated by spaces.
Print a single line containing two space-separated integers: the maximum simultaneous count of local vendors followed by the maximum simultaneous count of guest vendors.
This problem can be efficiently solved by running a sweep-line algorithm twice, once for each vendor type.
3
2 5 local
1 4 guest
3 7 local
2 1
- Local Vendors: Intervals are `[2, 5)` and `[3, 7)`.
- At time 2, one local stall opens. (Active: 1)
- At time 3, another local stall opens. (Active: 2) This is the peak.
- At time 5, the first local stall closes. (Active: 1)
- At time 7, the second local stall closes. (Active: 0)
The maximum number of simultaneous local vendors is 2.
- Guest Vendors: Interval is `[1, 4)`. The maximum number of simultaneous guest vendors is 1.
4
1 5 local
6 10 local
2 7 guest
8 12 guest
1 1
- Local Vendors: Intervals `[1, 5)` and `[6, 10)` do not overlap. The maximum active at any time is 1.
- Guest Vendors:** Intervals `[2, 7)` and `[8, 12)` do not overlap. The maximum active at any time is 1.
The expected time complexity is O(N log N).
1 <= N <= 10^5
0 <= start < end <= 10^9
Time limit: 1 sec