题库练习 Optimal Point on a Line
← 上一题 下一题 →

A10490 | Optimal Point on a Line

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given $n$ points on a line with their coordinates $x_{i}$ . Find the point $x$ so the sum of distances to the given points is minimal.

输入格式

The first line contains integer $n$ ( $1<=n<=3·10^{5}$ ) — the number of points on the line.

The second line contains $n$ integers $x_{i}$ ( $-10^{9}<=x_{i}<=10^{9}$ ) — the coordinates of the given $n$ points.

输出格式

Print the only integer $x$ — the position of the optimal point on the line. If there are several optimal points print the position of the leftmost one. It is guaranteed that the answer is always the integer.

输入输出样例

输入 #1
4
1 2 3 4
输出 #1
2
C++ 编辑器
输入
输出