DMOPC '14 Contest 5 P2 - Longest Tunnel

View as PDF

Submit solution


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

Author:
Problem type

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

Input Specification

The first line of input will contain the single integer N (1N500).
For each of the next N lines, line t will contain two space-separated integer values Xt1 and Xt2 (0Xt1<Xt2109).

Output Specification

On one line, the length of the longest tunnel.

Sample Input

Copy
3
1 8
9 150
0 81

Sample Output

Copy
141

Comments


  • 2
    tallinn  commented on Dec. 16, 2024, 3:40 p.m.

    Sean Combs


  • 1
    SagarSaha  commented on July 2, 2020, 3:33 a.m.

    what if two tunnels are the same length?


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

      down voting so toxic. valid question bro


    • 5
      maxcruickshanks  commented on July 2, 2020, 7: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).


      • 3
        0Power10  commented on July 20, 2021, 9:01 p.m.

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