codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

792A.md (1737B)


      1 Source: https://codeforces.com/problemset/problem/792/A
      2 
      3 A. New Bus Route
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 There are *n* cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers *a*1, *a*2, ..., *a**n*. All coordinates are pairwise distinct.
     22 
     23 It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build a new bus route. The Minister doesn't want to spend large amounts of money — he wants to choose two cities in such a way that the distance between them is minimal possible. The distance between two cities is equal to the absolute value of the difference between their coordinates.
     24 
     25 It is possible that there are multiple pairs of cities with minimal possible distance, so the Minister wants to know the quantity of such pairs.
     26 
     27 Your task is to write a program that will calculate the minimal possible distance between two pairs of cities and the quantity of pairs which have this distance.
     28 
     29 Input
     30 
     31 The first line contains one integer number *n* (2 ≤ *n* ≤ 2·105).
     32 
     33 The second line contains *n* integer numbers *a*1, *a*2, ..., *a**n* ( - 109 ≤ *a**i* ≤ 109). All numbers *a**i* are pairwise distinct.
     34 
     35 Output
     36 
     37 Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 4  
     45 6 -3 0 4
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 2 1
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 3  
     58 -2 0 2
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 2 2
     65 ```
     66 
     67 Note
     68 
     69 In the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.