Limits 1s, 512 MB

Rafi lives in a 2D2D space. He wants to participate in the “Take-off Programming Contest Spring 2023” with a friend. Alas! He has no friends, and he feels lonely. So he thought to himself that he needed a friend in his life to fill this emptiness. But he only wants to be friends with someone who lives closest to his house.

Rafi came to you for help with this situation. Now you have to write a program to help him decide who will be his friend. Rafi himself lives in origin (0,0)(0,0)


The first line will be a single integer NN (1N105)(1 \le N \le 10^5) indicating the number of Rafi's neighbors. The following NN lines will contain two integers AA and BB (0A,B109)(0 \le A,B \le 10^9) and (A+B>0)(A+B > 0) separated by a space. Where AA and BB are the positions of his neighbors' houses.


You have to print a line consisting of the coordinate as XX and YY separated by space which is the position of his new friend.

Check out the samples for clarification.


2 2
3 3
4 4
5 5
10 10
2 2
1 9
2 3
4 5
2 3

Rafi lives in the “Origin” (0,0)(0,0) coordinate of the 2D2D space. (Look at the figure for better understanding). Distances for all the given test cases will be unique.

Formula of Distance Between Two coordinate is, (x2x1)2+(y2y1)2\sqrt{ (x_2 - x_1)^2 + (y_2 - y_1)^2 }

Be careful about the newline(‘\n’) at the end.


Login to submit.


72% Solution Ratio
Asif_AlimEarliest, May '23
user.3392Fastest, 0.0s
user.3392Lightest, 4.9 MB
user.4210Shortest, 301B
Toph uses cookies. By continuing you agree to our Cookie Policy.