CF34A.Reconnaissance 2

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

nn soldiers stand in a circle. For each soldier his height aia_{i} is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. aiaj|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.

输入格式

The first line contains integer nn ( 2<=n<=1002<=n<=100 ) — amount of soldiers. Then follow the heights of the soldiers in their order in the circle — nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=10001<=a_{i}<=1000 ). The soldier heights are given in clockwise or counterclockwise direction.

输出格式

Output two integers — indexes of neighbouring soldiers, who should form a reconnaissance unit. If there are many optimum 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
    

说明/提示

题目描述:

操场上有 nn 个士兵站成了一个环,每名士兵有一个身高 hih_i,试求两相邻士兵 x,yx,y,使得士兵 xx 和士兵 yy 身高差最小。

输入:

第一行 nn,之后 nn 个整数 hih_i

输出:

题目描述中的 x,yx,y,若有多解任意输出一组即可。

数据范围:

2n100,1hi10002\leq n\leq100,1\leq h_i\leq1000

Translated by @稀神探女,Reformed by @chenyilai

首页