← Back to the problem

Kazakhstan FAIO 2024 · Statement

J. Dividing the Stars

Formatted by IOAI Training from the original (BeksultanSagyndyk/faio-tasks, licence Apache-2.0). The original is authoritative.

https://contest.yandex.ru/contest/71291/problems/J/

Time limit: 1 second
Memory limit: 64 MB
Input: standard input or input.txt
Output: standard output or output.txt

On a plane, there are marked neutron stars and giant stars. No three stars lie on the same straight line.

You are given an integer n.
The next n lines contain the coordinates of the neutron stars (two real numbers per line).
The following n lines contain the coordinates of the giant stars (two real numbers per line).

Find a line of the form [ y = a x + b ] that passes through one neutron star and one giant star such that, in one of the open half-planes determined by this line, the numbers of neutron stars and giant stars are equal. It is guaranteed that a solution of the form (y = ax + b) exists.

Input

  • n
  • n lines: x y for neutron stars (real numbers)
  • n lines: x y for giant stars (real numbers)

Output
Print a and b separated by a space.

Constraints

  • (1 < n < 10^5)
  • All coordinates are real numbers with (0 < x,y < 10^6)
  • No three stars are collinear.