Closest to the Origin
Among N points, print the one closest to the origin (Euclidean). Break distance ties by smaller x, then smaller y.
Input: the first line has N; the next N lines each have x y.
Output: the winning point's coordinates.
Constraints:
- 1 ≤ N ≤ 5×104
- |coordinates| ≤ 106
Sample Tests
Input 1
3 3 4 1 2 -1 2
Output 1
-1 2
Input 2
1 0 0
Output 2
0 0
Discussion (opens after you solve — no spoilers before)
No comments yet.