304774: CF911A. Nearest Minimums

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Nearest Minimums

题意翻译

给定一个长度为n的整数数组,请找出最小值之间的最短距离。保证最小值在数组中至少出现2次。

题目描述

You are given an array of $ n $ integer numbers $ a_{0},a_{1},...,a_{n-1} $ . Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times. 找到一个长度为n的序列中,距离最短的最小值的距离。

输入输出格式

输入格式


The first line contains positive integer $ n $ ( $ 2<=n<=10^{5} $ ) — size of the given array. The second line contains $ n $ integers $ a_{0},a_{1},...,a_{n-1} $ ( $ 1<=a_{i}<=10^{9} $ ) — elements of the array. It is guaranteed that in the array a minimum occurs at least two times.

输出格式


Print the only number — distance between two nearest minimums in the array.

输入输出样例

输入样例 #1

2
3 3

输出样例 #1

1

输入样例 #2

3
5 6 5

输出样例 #2

2

输入样例 #3

9
2 1 3 5 4 1 2 3 1

输出样例 #3

3

Input

题意翻译

给定一个长度为n的整数数组,请找出最小值之间的最短距离。保证最小值在数组中至少出现2次。

加入题单

上一题 下一题 算法标签: