luogu#P5199. [USACO19JAN] Mountain View S

[USACO19JAN] Mountain View S

Background

USACO January 2019 Contest, Silver Problem 3.

Problem Description

Looking into the distance from the pasture of the cow Bessie, she can see a magnificent mountain range stretching along the horizon. The range contains NN mountain peaks (1N1051 \le N \le 10^5). If we imagine Bessie’s view as the xyxy-plane, then each mountain is a triangle whose base lies on the xx-axis. Both sides of the triangle make a 4545 degree angle with the base, so the вершина (pinnacle, "fengding") is a right angle. Therefore, mountain ii can be described exactly by the coordinates of its peak (xi,yi)(x_i, y_i). No two mountains have exactly the same peak coordinates.

Bessie tries to count all the mountains. However, because they are almost the same color, if the peak of one mountain lies on the boundary or inside the triangular region of another mountain, she cannot distinguish it.

Find the number of distinct mountain peaks that Bessie can see, i.e. the number of visible mountains.

Input Format

The first line contains NN. The next NN lines each contain xix_i (0xi1090 \le x_i \le 10^9) and yiy_i (1yi1091 \le y_i \le 10^9), describing the coordinates of a mountain’s peak.

Output Format

Output the number of mountains that Bessie can distinguish.

3
4 6
7 2
2 5
2

Hint

In this example, Bessie can see the first and the last mountains. The second mountain is covered by the first mountain.

Translated by ChatGPT 5