社区讨论
是真的不会,大佬帮帮忙啊!
P8816[CSP-J 2022] 上升点列参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lzf8t3cw
- 此快照首次捕获于
- 2024/08/04 15:30 2 年前
- 此快照最后确认于
- 2024/08/04 15:45 2 年前
CPP
#include <iostream>
#include <cmath>
using namespace std;
typedef long long shuju;
struct zuobiao
{
shuju x;
shuju y;
};
int main()
{
shuju n=0;
shuju k=0;
shuju tag=0;
cin>>n>>k;
zuobiao a[510];
shuju X=0;
shuju Y=0;
for(shuju i=0;i<n;i++)
{
cin>>a[i].x>>a[i].y;
if(X<a[i].x)
{
X=a[i].x;
}
if(Y<a[i].y)
{
Y=a[i].y;
}
}
for(shuju j=0;j<n;j++)
{
shuju yes=0;
shuju no=0;
shuju t=-1;
for(shuju p=0;p<n;p++)
{
if(a[p].y==a[j].y)
{
yes++;
if(t==-1)
{
t=p;
}
else
{
no+=a[p].y-a[t].y;
t=p;
}
}
}
if(tag<yes+k&&no<=k)
{
tag=yes+k;
}
}
for(shuju j=0;j<n;j++)
{
shuju yes=0;
shuju no=0;
shuju t=-1;
for(shuju p=0;p<n;p++)
{
if(a[p].x==a[j].x)
{
yes++;
if(t==-1)
{
t=p;
}
else
{
no+=a[p].x-a[t].x;
t=p;
}
}
}
if(tag<yes+k&&no<=k)
{
tag=yes+k;
}
}
cout<<tag<<endl;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...