/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君の家のフェンスには N 枚の板が一列に立っています。左端を 0 として、左から i 番目の板は位置 A_i にあります。板の位置は左から順に大きくなっており、 A_1 < A_2 < \cdots < A_N です。
隣り合う板の間の隙間は N - 1 か所あります。左から i 番目の板と i + 1 番目の板の間の隙間の幅は A_{i+1} - A_i です。
最も広い隙間は左から何番目の隙間かを求めてください。最も広い隙間が複数ある場合は、そのうち最も左のものを答えてください。
制約
- 2 \leq N \leq 100
- 0 \leq A_1 < A_2 < \cdots < A_N \leq 10000
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
- 1 行目には、板の枚数 N が与えられる。
- 2 行目には、各板の位置 A_1, A_2, \ldots, A_N がスペース区切りで与えられる。
出力
最も広い隙間が左から何番目かを 1 行で出力せよ。複数ある場合は最も左のものを出力せよ。
入力例 1
4 0 3 10 12
出力例 1
2
入力例 2
2 5 9
出力例 2
1
入力例 3
5 1 2 4 8 20
出力例 3
4
入力例 4
15 78 92 112 198 257 352 391 462 536 610 638 702 738 751 821
出力例 4
5
入力例 5
4 0 4 10 24
出力例 5
3
Score : 233 pts
Problem Statement
There are N boards standing in a row on the fence of Takahashi's house. Taking the left end as position 0, the i-th board from the left is at position A_i. The positions of the boards increase from left to right: A_1 < A_2 < \cdots < A_N.
There are N - 1 gaps between consecutive boards. The width of the gap between the i-th and (i+1)-th boards from the left is A_{i+1} - A_i.
Find the index (counted from the left) of the widest gap. If there are multiple widest gaps, answer the leftmost one.
Constraints
- 2 \leq N \leq 100
- 0 \leq A_1 < A_2 < \cdots < A_N \leq 10000
- All input values are integers.
Input
The input is given from standard input in the following format.
N A_1 A_2 \ldots A_N
- The first line contains the number of boards N.
- The second line contains the positions A_1, A_2, \ldots, A_N of the boards, separated by spaces.
Output
Print, in a single line, the index (counted from the left) of the widest gap. If there are multiple such gaps, print the leftmost one.
Sample Input 1
4 0 3 10 12
Sample Output 1
2
Sample Input 2
2 5 9
Sample Output 2
1
Sample Input 3
5 1 2 4 8 20
Sample Output 3
4
Sample Input 4
15 78 92 112 198 257 352 391 462 536 610 638 702 738 751 821
Sample Output 4
5
Sample Input 5
4 0 4 10 24
Sample Output 5
3