Setting the video

Professor Oak is a great fan of Takeshi’s castle. So much, that he has
bought a satellite antenna to watch the show in several European
channels. Professor Oak has a guide of all the channels of Europe, and
wants to set his video to record as many episodes as possible. But it is
not easy: The video only can record a channel at a time. Moreover, the
episodes can have different lengths (depending on how they are edited,
the advertiments, etc).

Can you help professor Oak? Write a program that, given the beginning
time and end time of the broadcast of all the episodes of Takeshi’s
castle in all the european channels during several days, computes the
maximum number of episodes that can be recorded every day.

Input

Input consists of several cases. Each case has a natural number
1 ≤ n ≤ 10⁵ followed by n pairs (i₁, f₁), …, (i_(n), f_(n)) of natural
numbers that indicate the beginning time and the end time, both of them
included, of each episode of a day. For any j between 1 and n, assume
0 ≤ i_(j) ≤ f_(j) ≤ 10⁹.

Output

For each case of the input, print a line with the maximum number of
complete episodes that professor Oak will be able to record that day.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:01:26.205Z

© Jutge.org, 2006–2026.
https://jutge.org
