#P6283. [USACO20OPEN] The Moo Particle S

[USACO20OPEN] The Moo Particle S

Description

FJ’s cows have been bored lately, so they came up with a brand-new way to kill time: studying advanced physics. In fact, they even managed to discover a new subatomic particle, which they named the “Moo Particle”.

The cows are running an experiment involving NN Moo Particles (1N1051\le N\le 10^5). The “spin” of particle ii can be described by two integers xix_i and yiy_i in the range 109109-10^9\ldots 10^9. Sometimes two Moo Particles interact. Two particles with spins (xi,yi)(x_i,y_i) and (xj,yj)(x_j,y_j) will interact if and only if xixjx_i\le x_j and yiyjy_i\le y_j. Under these conditions, it is possible for one of the two particles to disappear (the other particle does not change). At any given moment, at most one interaction can happen.

The cows want to know the minimum number of Moo Particles that can remain after performing some sequence of interactions.

Input Format

The first line contains an integer NN, the initial number of Moo Particles. The next NN lines each contain two space-separated integers, representing the spin of one particle. All particle spins are distinct.

Output Format

Output one integer, the minimum number of Moo Particles that can remain after performing some sequence of interactions.

4
1 0
0 1
-1 0
0 -1
1
3
0 0
1 1
-1 3
2

Hint

Explanation for Sample Input/Output 1

One possible sequence of interactions:

  • Particle 11 interacts with particle 44, and particle 11 disappears.
  • Particle 22 interacts with particle 44, and particle 44 disappears.
  • Particle 22 interacts with particle 33, and particle 33 disappears. Only particle 22 remains.

Explanation for Sample Input/Output 2

Particle 33 cannot interact with any other particle, so it must remain. Among particles 11 and 22, at least one must remain.

Subtasks

  • Test cases 33-66 satisfy N103N\le 10^3.
  • Test cases 77-1212 have no additional constraints.

Translated by ChatGPT 5