#C1430. Minimum Delivery Routes

    ID: 43934 Type: Default 1000ms 256MiB

Minimum Delivery Routes

Minimum Delivery Routes

You are given a set of packages, each with a start time and an end time representing the delivery window. Your task is to determine the minimum number of delivery routes required so that each package is delivered on time. A single delivery route can deliver consecutive packages if the end time of the previous package is less than or equal to the start time of the next package. Formally, given n packages with intervals \( [s_i, e_i] \), find the minimum number of non-overlapping routes such that every package is assigned to a route.

Input Constraints:

  • The first line contains an integer n denoting the number of packages.
  • The following n lines each contain two space-separated integers \( s_i \) and \( e_i \) where \( s_i \) is the start time and \( e_i \) is the end time.

Example: For input 3\n1 4\n2 6\n8 10, one optimal assignment requires 2 routes.

inputFormat

The input is read from standard input (stdin) and has the following format:


 
 
... 
 

Where n is the number of packages, and each subsequent line contains two integers representing the start time and end time of a package.

outputFormat

Output the minimum number of delivery routes required. The result should be printed to standard output (stdout).

## sample
3
1 4
2 6
8 10
2

</p>