#C11910. Maximum Simultaneous Participants
Maximum Simultaneous Participants
Maximum Simultaneous Participants
You are given an event with multiple participants. Each participant is defined by a start time and an end time, indicating when they begin and finish their participation in the event. Your task is to determine the maximum number of participants that are simultaneously active at any moment during the event.
For each test case, you will be provided an integer N representing the number of participants, followed by 2N integers. In these 2N integers, every pair defines a participant's start time and finish time respectively.
Note: If a start time and an end time occur at the same moment, the participant finishing (end time) is considered to have ended before a new one starts. Mathematically, for events occurring at time t, if two events coincide then the 'end' event is processed before the 'start' event.
The solution might involve simulating all events by converting start and finish times into separate events and then sorting them. The maximum number of simultaneous participants can then be determined by iterating through these events and counting the number of currently active participants.
inputFormat
Standard input consists of multiple test cases. The first line contains a single integer T that indicates the number of test cases. For each test case:
- The first line contains an integer N indicating the number of participants.
- The second line contains 2N space-separated integers. The first integer in each pair is the start time and the second is the finish time for a participant.
Example:
1 3 1 4 2 5 3 6
outputFormat
For each test case, output a single line containing one integer: the maximum number of participants that are active simultaneously.
Example:
3## sample
1
3
1 4 2 5 3 6
3
</p>