CF34A.Reconnaissance 2

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

n soldiers stand in a circle. For each soldier, his height a__i is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose height difference is minimal, i.e. |a__i - a__j| is minimal. So each of them will be less noticeable with the other. Output any pair of soldiers that can form a reconnaissance unit.

有 n 名士兵围成一个圆圈站立。对于每名士兵,已知其身高 a__i。侦察小队可由两名相邻的士兵组成,要求他们的身高差最小,即 |a__i - a__j| 最小。这样,两人彼此之间便更不易被察觉。输出任意一对可以组成侦察小队的士兵。

输入格式

The first line contains an integer n (2 ≤ n ≤ 100) — the number of soldiers. Then follow the heights of the soldiers in their order in the circle — n space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 1000). The soldier heights are given in a clockwise or counterclockwise direction.

第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100)—— 士兵的数量。接下来的一行按士兵在圆圈中的顺序给出他们的身高——nn 个用空格分隔的整数 a1, a2, …, ana_1,\ a_2,\ \dots,\ a_n(1≤ai≤10001 \leq a_i \leq 1000)。士兵的身高按顺时针或逆时针方向给出。

输出格式

Output two integers — indices of neighbouring soldiers, who should form a reconnaissance unit. If there are many optimal solutions, output any of them. Remember that the soldiers stand in a circle.

输出两个整数——应组成侦察小队的相邻士兵的索引。若存在多个最优解,输出任意一个即可。注意:士兵围成一个圆圈站立。

输入输出样例

  • 输入#1

    5
    10 12 13 15 10

    输出#1

    5 1
  • 输入#2

    4
    10 20 30 40

    输出#2

    1 2

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

首页