A7949 | Reconnaissance 2
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
$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 heights 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.
输入格式
The first line contains integer $n$ ( $2<=n<=100$ ) — amount 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 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
#### 题目描述:
操场上有 $n$ 个士兵站成了一个环,每名士兵有一个身高 $h_i$,试求两相邻士兵 $x,y$,使得士兵 $x$ 和士兵 $y$ 身高差最小。
#### 输入:
第一行 $n$,之后 $n$ 个整数 $h_i$。
#### 输出:
题目描述中的 $x,y$,若有多解任意输出一组即可。
#### 数据范围:
$2\leq n\leq100,1\leq h_i\leq1000$
Translated by @[稀神探女](/user/85216),Reformed by @[chenyilai](/user/249879)。
操场上有 $n$ 个士兵站成了一个环,每名士兵有一个身高 $h_i$,试求两相邻士兵 $x,y$,使得士兵 $x$ 和士兵 $y$ 身高差最小。
#### 输入:
第一行 $n$,之后 $n$ 个整数 $h_i$。
#### 输出:
题目描述中的 $x,y$,若有多解任意输出一组即可。
#### 数据范围:
$2\leq n\leq100,1\leq h_i\leq1000$
Translated by @[稀神探女](/user/85216),Reformed by @[chenyilai](/user/249879)。
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted