CF792A.New Bus Route

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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.

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.

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.

伯兰主干道上分布着 nn 座城市。每座城市由其坐标表示——整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n。所有坐标两两互不相同。

城市之间仅能通过公交车通行。但所有公交车和道路都非常陈旧,因此交通部长决定修建一条新的公交线路。部长不想花费大量资金——他希望选出两座城市,使得它们之间的距离尽可能小。两座城市之间的距离定义为它们坐标之差的绝对值。

可能存在多对城市具有相同的最小可能距离,因此部长希望知道满足该最小距离的城市对的数量。

你的任务是编写一个程序,计算所有城市对中可能的最小距离,以及具有该最小距离的城市对的数量。

输入格式

The first line contains one integer number n (2 ≤ n ≤ 2·105).

The second line contains n integer numbers _a_1, _a_2, ..., a__n ( - 109 ≤ a__i ≤ 109). All numbers a__i are pairwise distinct.

第一行包含一个整数 $ n (( 2 \leq n \leq 2 \cdot 10^5 $)。

第二行包含 $ n $ 个整数 $ a_1, a_2, \ldots, a_n (( -10^9 \leq a_i \leq 10^9 $)。所有 $ a_i $ 两两不同。

输出格式

Print two integer numbers — the minimal distance and the quantity of pairs with this distance.

输出两个整数——最小距离以及具有该距离的点对数量。

输入输出样例

  • 输入#1

    4
    6 -3 0 4

    输出#1

    2 1
  • 输入#2

    3
    -2 0 2

    输出#2

    2 2

说明/提示

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.

在第一个例子中,第一座城市与第四座城市之间的距离为 ∣4 − 6∣ = 2|4 - 6| = 2,且这是唯一一对具有该距离的城市。

输入解题思路,AI测评打分。不知道怎么写?

首页