P4165 [SCOI2007]组队

# include <bits/stdc++.h>
# define re register
# define N 5050
using namespace std;
int n,a,b,c;
int ans;

struct node
{
int h;//高度
int v;//速度
int sum;
}e[N];

int cmp1(const node &a,const node &b) {return a.h>b.h;}//按高度排序
int cmp2(const node &a,const node &b) {return a.sum>b.sum;}//按总属性排序

node f[N];

int main()
{
ios::sync_with_stdio(false);

cin>>n>>a>>b>>c;
for(int i = 1; i <= n; i++)
{
cin>>e[i].h>>e[i].v;
e[i].sum = a*e[i].h + b*e[i].v;//总属性
f[i] = e[i];
}

sort(e+1,e+n+1,cmp1);
sort(f+1,f+n+1,cmp2);

int l,r,cnt;

for(int i = 1; i <= n; i++)
{
l = r = 0;
cnt = 0;
int maxn = e[i].v + c/b;
for(int j = 1; j <= n; j++)
{
while(r < n && f[r+1].sum <= a*e[j].h+b*e[i].v+c)
{
r++;
if(f[r].v >= e[i].v && f[r].v <= maxn) cnt++;
}
while(l < n && e[l+1].h < e[j].h)
{
l++;
if(e[l].v >= e[i].v && e[l].v <= maxn) cnt--;
}
}
ans = max(ans , cnt);
}

cout<<ans<<endl;
return 0;
}

转载于:https://www.cnblogs.com/fsf-fighting/p/9585310.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值