

Time Limit: 2.525 sec / Memory Limit: 1024 MB
配点 : 点
問題文
ドワンゴ社員のニワンゴくんは、投稿された動画からサムネイルを生成する機能を実装することになりました。
動画からサムネイルとするフレームを選択する手順は以下の通りです。
- 動画の総フレーム数 と、動画の各フレームを1つの整数で表現した長さ の整数列 を入力として受け取る
- 各フレームには、先頭から順番に のフレーム番号が付いており、フレーム番号 を表現する整数は である
- の平均値に最も近いフレームをサムネイルとする
- そのようなフレームが複数ある場合、それらの中で最もフレーム番号の小さいものをサムネイルとする
この手順で得られる、サムネイルとして選択されるフレーム番号を出力してください。
制約
- 入力として与えられる数値はすべて整数である
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例1Copy
3 1 2 3
出力例1Copy
1
の平均値は ですので、最も近いフレーム番号 が選択されます。
入力例2Copy
4 2 5 2 5
出力例2Copy
0
の平均値は ですが、平均値との距離は全フレーム同じです。よって、それらの中で最もフレーム番号の小さい が選択されます。
Score : points
Problem Statement
Niwango-kun is an employee of Dwango Co., Ltd.
One day, he is asked to generate a thumbnail from a video a user submitted.
To generate a thumbnail, he needs to select a frame of the video according to the following procedure:
- Get an integer and integers as inputs. denotes the number of the frames of the video, and each denotes the representation of the -th frame of the video.
- Select -th frame whose representation is nearest to the average of all frame representations.
- If there are multiple such frames, select the frame with the smallest index.
Find the index of the frame he should select to generate a thumbnail.
Constraints
- All numbers given in input are integers
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
3 1 2 3
Sample Output 1Copy
1
Since the average of frame representations is , Niwango-kun needs to select the index , whose representation is , that is, the nearest value to the average.
Sample Input 2Copy
4 2 5 2 5
Sample Output 2Copy
0
The average of frame representations is .
In this case, every frame has the same distance from its representation to the average.
Therefore, Niwango-kun should select index , the smallest index among them.