1177: [CSP-J 2022] 上升点列

文件提交:无需freopen 内存限制:512 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

在一个二维平面内,给定 lns="http://www.w3.org/1998/Math/MathML"> 个整数点 lns="http://www.w3.org/1998/Math/MathML">(,),此外你还可以自由添加 lns="http://www.w3.org/1998/Math/MathML"> 个整数点。

你在自由添加 lns="http://www.w3.org/1998/Math/MathML"> 个点后,还需要从 lns="http://www.w3.org/1998/Math/MathML">+ 个点中选出若干个整数点并组成一个序列,使得序列中任意相邻两点间的欧几里得距离恰好为 lns="http://www.w3.org/1998/Math/MathML">1 而且横坐标、纵坐标值均单调不减,即 lns="http://www.w3.org/1998/Math/MathML">+1=1,+1= 或 lns="http://www.w3.org/1998/Math/MathML">+1=1,+1=。请给出满足条件的序列的最大长度。

输入

第一行两个正整数 lns="http://www.w3.org/1998/Math/MathML">, 分别表示给定的整点个数、可自由添加的整点个数。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,第 lns="http://www.w3.org/1998/Math/MathML"> 行两个正整数 lns="http://www.w3.org/1998/Math/MathML">, 表示给定的第 lns="http://www.w3.org/1998/Math/MathML"> 个点的横纵坐标。

输出

输出一个整数表示满足要求的序列的最大长度。

样例输入

8 2
3 1
3 2
3 3
3 6
1 2
2 2
5 5
5 3

样例输出

8

提示

保证对于所有数据满足:lns="http://www.w3.org/1998/Math/MathML">1500lns="http://www.w3.org/1998/Math/MathML">0100。对于所有给定的整点,其横纵坐标 lns="http://www.w3.org/1998/Math/MathML">1,109,且保证所有给定的点互不重合。对于自由添加的整点,其横纵坐标不受限制。

测试点编号 lns="http://www.w3.org/1998/Math/MathML"> lns="http://www.w3.org/1998/Math/MathML"> lns="http://www.w3.org/1998/Math/MathML">,
lns="http://www.w3.org/1998/Math/MathML">12 lns="http://www.w3.org/1998/Math/MathML">10 lns="http://www.w3.org/1998/Math/MathML">0 lns="http://www.w3.org/1998/Math/MathML">10
lns="http://www.w3.org/1998/Math/MathML">34 lns="http://www.w3.org/1998/Math/MathML">10 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">100
lns="http://www.w3.org/1998/Math/MathML">57 lns="http://www.w3.org/1998/Math/MathML">500 lns="http://www.w3.org/1998/Math/MathML">0 lns="http://www.w3.org/1998/Math/MathML">100
lns="http://www.w3.org/1998/Math/MathML">810 lns="http://www.w3.org/1998/Math/MathML">500 lns="http://www.w3.org/1998/Math/MathML">0 lns="http://www.w3.org/1998/Math/MathML">109
lns="http://www.w3.org/1998/Math/MathML">1115 lns="http://www.w3.org/1998/Math/MathML">500 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">100
lns="http://www.w3.org/1998/Math/MathML">1620 lns="http://www.w3.org/1998/Math/MathML">500 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">109