## DMOPC '14 Contest 5 P2 - Longest Tunnel

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Simon likes drilling tunnels parallel to the ground. Simon has drilled horizontal line tunnels. Each tunnel starts from and ends at . What is the length of the longest tunnel that Simon has dug?

#### Input Specification

The first line of input will contain the single integer .
For each of the next lines, line will contain two space-separated integer values and .

#### Output Specification

On one line, the length of the longest tunnel.

#### Sample Input

3
1 8
9 150
0 81

#### Sample Output

141

• commented on July 1, 2020, 11:33 p.m.

what if two tunnels are the same length?

• commented on March 24, 2022, 1:19 p.m.

down voting so toxic. valid question bro

• commented on July 2, 2020, 3:34 p.m.

You only need to find the longest tunnel, so you can choose either tunnel (if they're tied for the maximum length).

• commented on July 20, 2021, 5:01 p.m.

indeed, since your printing out the length not which tunnel it is