Defence Towers

mediummathshashmapGeometry

You are a commander of a defense tower located at the origin $$$(0, 0)$$$ of a 2D Cartesian plane. You are given the coordinates of $$$N$$$ enemies. Your tower can fire a single, powerful laser beam in a straight line that must pass through the origin. This laser strike eliminates all enemies positioned along its path.

Your objective is to determine the maximum number of enemies you can eliminate with a single shot.

Input Format:

The first line of input contains a single integer $$$N$$$ ($$$1 \le N \le 2\cdot10^5$$$), representing the number of enemies.

The following $$$N$$$ lines each contain two space-separated integers, $$$x_i$$$ and $$$y_i$$$ ($$$-10^9 \le x_i, y_i \le 10^9$$$), representing the coordinates of the $$$i$$$-th enemy.

Output Format:

Print a single integer: the maximum number of enemies that can be eliminated by a single laser strike.

Examples:

Example 1:

Input:

5
1 1
2 2
-1 -1
1 2
2 1

Output:

3

Example 2:

Input:

1
10 -10

Output:

1

Note:

Example 1:

Out of all the lasers that the tower is using to kill at least one enemy and that also pass through the origin itself, the green laser benefits the most, as it allows the defense tower to kill $$$3$$$ enemies.

Code

Loading Editor...