#K7976. Minimum Teams Required

    ID: 35380 Type: Default 1000ms 256MiB

Minimum Teams Required

Minimum Teams Required

Given several projects each defined by a starting date and an ending date, determine the minimum number of teams required so that every project can be staffed without any overlap in workload for any team.

Two projects are considered overlapping if they share any common time. Formally, if you represent each project by an interval \([s_i, e_i]\), then you need to compute the maximum number of intervals that overlap at any time point. That value is the minimum number of teams required.

This can be expressed mathematically as: \[ \text{teams} = \max_{t} \left\{ \#\{ i : s_i \le t \le e_i \} \right\} \]

inputFormat

The input is received from standard input (stdin) and consists of:

  1. An integer N representing the number of projects.
  2. N subsequent lines, each containing two space-separated integers s and e representing the starting and ending time of a project.

outputFormat

Output a single integer to standard output (stdout): the minimum number of teams required to complete all projects without any overlapping assignments.

## sample
3
1 4
2 5
4 6
2