DMOPC '14 Contest 6 P2 - Longest Tunnel

View as PDF

Submit solution


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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Simon likes drilling tunnels parallel to the ground. Simon has drilled N horizontal line tunnels. Each tunnel t starts from X_{t_1} and ends at X_{t_2}. 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 (1 \le N \le 500) .
For each of the next N lines, line t will contain two space-separated integer values X_{t_1} and X_{t_2} (0 \le X_{t_1} < X_{t_2} \le 10^9).

Output Specification

On one line, the length of the longest tunnel.

Sample Input

3
1 8
9 150
0 81

Sample Output

141

Comments


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

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 2
      maxcruickshanks  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).