PDP-17 (2005) - Phase C' - 6 (crocodiles) **

View as PDF

Submit solution

Points: 35 (partial)
Time limit: 1.2s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

Crocodiles

Given the birth year and the death year of N crocodiles, the problem is to find the maximum number of crocodiles alive at any given time.

Input

A file named crocodiles.in contains an integer N (where 0 < N < 300.000) on the first line, indicating the number of lines that follow. Each of the following lines contains two integers within the range [-100.000 .. 100.000], representing respectively the birth year and the death year of each crocodile. There is a single space between the two integers.

Note that the death year is not included in the crocodile's lifespan. That is, if a crocodile is born in 2001 and dies in 2005, it lived for 4 years.

Output

A file named crocodiles.out containing an integer indicating the maximum number of living crocodiles at any given time. The output file should end with a newline character.

Example of Input - Output Data

STDIN (qubits.in)

4
12 50
10 60
-90000 -89950
48 55

STDOUT (qubits.out)

3

Maximum execution time: 1,2 sec.


Comments

There are no comments at the moment.