LCC '25 Contest 1 J4 - Candy Delivery

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Java 1.8s
Memory limit: 256M

Author:
Problem types

Nightlqht, the other MCPT president, owns the most popular candy factory in the city! He has recently opened his delivery service, but unbeknownst to him, all his ghostly delivery drivers seem to have vanished! He has to resort to his latest machine: The CandyFlare.

The instructions of the CandyFlare are as follows:

Aim the CandyCannon (which shoots CandyFlares) in the direction you want.

Press the big red launch button (NOT THE NUCLEAR MISSILE ONE!!!).

Watch as it sails straight like an arrow to infinity while dropping candy along its path.

The city can be modeled using coordinates relative to Nightlqht's factory (which is located at (0,0).) There are N houses that require candy delivery, and each house is located at a distinct point (x_i,y_i). What is the minimum number of flares that he needs to send for each house to receive candy?

Subtasks

1 \leq N \leq 10^5

-10^9 \leq x_i,y_i \leq 10^9

Subtask 1 [20%]

1 \leq N \leq 100

1 \leq x_i,y_i \leq 10^3

Subtask 2 [30%]

1 \leq N \leq 10^3

0 \leq x_i,y_i \leq 10^9

Subtask 3 [50%]

No further subtasks.

Input Specification

The first line will contain the integer N.

Each of the next N lines will contain space-separated integers x_i,y_i, the coordinates of the i^{\text{th}} house.

Output Specification

Output a single integer indicating the minimum number of flares that need to be shot for all N houses to receive candy from them.

Sample Input

4
2 2
1 2
3 3
-4 -8

Sample Output

3

Explanation for Sample Output

By sending a flare along the line y=x towards Quadrant I, the flare will pass over houses at (2,2) and (3,3). We must send 2 flares along the line y=2x, one towards Quadrant I and one towards Quadrant III. This is because the flare begins at the factory, which is at the origin.


Comments

There are no comments at the moment.