跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1110. Optimal Point on a Line

  • ID: 1116
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:基础
  • 上传者:
  • 枚举
  • 排序
  • 算法思想
  • 编程与模拟
  • 基础
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Optimal Point on a Line

题目描述

B. Optimal Point on a Line
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.

Input

The first line contains integer n (1≤n≤3·105) − the number of points on the line.

The second line contains n integers xi (-109≤xi≤109) − the coordinates of the given n points.

Output

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.

Example
Input
4
1 2 3 4
Output
2


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 577 题。保留原作者与原赛事署名。