CF911A.Nearest Minimums

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

给你一个包含 nn 个整数的数组 a0, a1, ..., an−1a_0, a_1, ..., a_{n-1}。请找出其中两个最接近(即距离最近)的最小值之间的距离。题目保证数组中最小值至少出现两次。

输入格式

The first line contains positive integer n (2 ≤ n ≤ 105) — size of the given array. The second line contains n integers _a_0, _a_1, ..., a__n - 1 (1 ≤ a__i ≤ 109) — elements of the array. It is guaranteed that in the array a minimum occurs at least two times.

第一行包含一个正整数 nn(2 ≤ n ≤ 1052 \leq n \leq 10^5)—— 给定数组的大小。
第二行包含 nn 个整数 a0, a1, ..., an−1a_0, a_1, ..., a_{n-1}(1 ≤ ai ≤ 1091 \leq a_i \leq 10^9)—— 数组的元素。
保证数组中最小值至少出现两次。

输出格式

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

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

首页