DMPG '17 S1 - Molly and Difference

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Molly loves subtraction. She also loves non-negative numbers. For her birthday, Molly received an array A1,A2,,AN of integers. To make up for the fact that you forgot to bring her a present, you decide to tell her the minimum value of d such that d=|AiAj|, such that 1i,jN.

Constraints

For all subtasks:

109Ai109

Subtask 1 [40%]

2N1000

Subtask 2 [60%]

2N106

Input Specification

Line 1: An integer, N.
Line 2: N space separated integers, the array A1,A2,,AN.

Output Specification

The minimum value of d.

Sample Input

Copy
5
21 -10 7 3 18

Sample Output

Copy
3

Comments


  • 1
    IanHu  commented on Dec. 10, 2018, 4:17 a.m.

    what should i do if i keep getting TLE in Batch #3, using JAVA..... Thanks


    • 3
      kingW3  commented on Dec. 10, 2018, 11:49 a.m.

      Use BufferedReader


      • -4
        IanHu  commented on Dec. 21, 2018, 4:29 a.m.

        Thanks :-)


  • 7
    Kirito  commented on April 25, 2017, 4:05 p.m. edited

    Hint for Python Coders getting TLE: Use PyPy instead.