#P8816. [CSP-J 2022] 上升点列

    ID: 9612 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划 DP2022O2优化CSP-J 入门级

[CSP-J 2022] 上升点列

Problem Description

On a two-dimensional plane, you are given nn integer points (xi,yi)(x_i, y_i). In addition, you may freely add kk integer points.

After adding kk points, you need to select some integer points from the n+kn + k points to form a sequence such that the Euclidean distance between any two adjacent points in the sequence is exactly 11, and both the xx-coordinate and the yy-coordinate are non-decreasing. That is, either xi+1xi=1,yi+1=yix_{i+1} - x_i = 1, y_{i+1} = y_i, or yi+1yi=1,xi+1=xiy_{i+1} - y_i = 1, x_{i+1} = x_i. Please output the maximum possible length of such a sequence.

Input Format

The first line contains two positive integers n,kn, k, representing the number of given integer points and the number of integer points you may freely add.

The next nn lines each contain two positive integers xi,yix_i, y_i, representing the coordinates of the ii-th given point.

Output Format

Output one integer representing the maximum length of a sequence that satisfies the requirements.

8 2
3 1
3 2
3 3
3 6
1 2
2 2
5 5
5 3
8
4 100
10 10
15 25
20 20
30 30
103

Hint

【Sample #3】

See point/point3.in and point/point3.ans in the attachments.

In the third sample, k=0k = 0.

【Sample #4】

See point/point4.in and point/point4.ans in the attachments.

【Constraints】

It is guaranteed that for all testdata: 1n5001 \leq n \leq 500, 0k1000 \leq k \leq 100. For all given integer points, 1xi,yi1091 \leq x_i, y_i \leq {10}^9, and all given points are distinct. For the integer points you add freely, the coordinates have no restrictions.

Test Point ID nn \leq kk \leq xi,yix_i, y_i \leq
121 \sim 2 1010 00 1010
343 \sim 4 100100 100100
575 \sim 7 500500 00
8108 \sim 10 109{10}^9
111511 \sim 15 100100 100100
162016 \sim 20 109{10}^9

Translated by ChatGPT 5