710B.md (862B)
1 Source: https://codeforces.com/problemset/problem/710/B 2 3 B. Optimal Point on a Line 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 Input 24 25 The first line contains integer *n* (1 ≤ *n* ≤ 3·105) — the number of points on the line. 26 27 The second line contains *n* integers *x**i* ( - 109 ≤ *x**i* ≤ 109) — the coordinates of the given *n* points. 28 29 Output 30 31 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. 32 33 Example 34 35 Input 36 37 ``` 38 4 39 1 2 3 4 40 ``` 41 42 Output 43 44 ``` 45 2 46 ```