#abc225e. E - 7

E - 7

Score : 500500 points

问题陈述

在平面的第一象限中绘制了 NN 个数字7。

ii 个7是一个图形,由连接点 (xi1,yi)(x_i-1,y_i)(xi,yi)(x_i,y_i) 的线段以及连接点 (xi,yi1)(x_i,y_i-1)(xi,yi)(x_i,y_i) 的线段组成。

你可以选择从这 NN 个7中删除零个或多个。

在最优删除后,从原点完全可见的7的最大数量是多少?

这里,第 ii 个7从原点完全可见当且仅当:

  • 以原点、点 (xi1,yi)(x_i-1,y_i)、点 (xi,yi)(x_i,y_i) 和点 (xi,yi1)(x_i,y_i-1) 为顶点构成的四边形(不包括边界)不与其他7相交。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN 7's drawn in the first quadrant of a plane.

The ii-th 7 is a figure composed of a segment connecting (xi1,yi)(x_i-1,y_i) and (xi,yi)(x_i,y_i), and a segment connecting (xi,yi1)(x_i,y_i-1) and (xi,yi)(x_i,y_i).

You can choose zero or more from the NN 7's and delete them.

What is the maximum possible number of 7's that are wholly visible from the origin after the optimal deletion?

Here, the ii-th 7 is wholly visible from the origin if and only if:

  • the interior (excluding borders) of the quadrilateral whose vertices are the origin, (xi1,yi)(x_i-1,y_i), (xi,yi)(x_i,y_i), (xi,yi1)(x_i,y_i-1) does not intersect with the other 7's.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1xi,yi1091 \leq x_i,y_i \leq 10^9
  • (xi,yi)(xj,yj) (ij)(x_i,y_i) \neq (x_j,y_j)\ (i \neq j)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 y1y_1

x2x_2 y2y_2

\hspace{0.45cm}\vdots

xNx_N yNy_N

Output

Print the maximum possible number of 7's that are wholly visible from the origin.

Sample Input 1

3
1 1
2 1
1 2

Sample Output 1

2

If the first 7 is deleted, the other two 7's ― the second and third ones ― will be wholly visible from the origin, which is optimal.

If no 7's are deleted, only the first 7 is wholly visible from the origin.

Sample Input 2

10
414598724 87552841
252911401 309688555
623249116 421714323
605059493 227199170
410455266 373748111
861647548 916369023
527772558 682124751
356101507 249887028
292258775 110762985
850583108 796044319

Sample Output 2

10

It is best to keep all 7's.

update @ 2024/3/10 09:53:39