Last Updated: 6 Oct, 2025

Festival Peak Vendors

Hard
Asked in company
Google inc

Problem statement

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:


1) The maximum number of local vendor stalls operating at the same time.


2) The maximum number of guest vendor stalls operating at the same time.


Input Format:
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.


Output Format:
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.


Note:
This problem can be efficiently solved by running a sweep-line algorithm twice, once for each vendor type.