bzoj1071

神奇的乱搞。。。被卡int了,结果换一下顺序居然就可以过了

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long LL;
inline int read()
{
    int x=0;char c=getchar();
    for (;c<'0'||c>'9';c=getchar());
    for (;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x;
}
const int N=5010;
int n,A,B,C,mn,mx,ans=1;
struct na
{
    int a,b,c;
}e[2][N];
inline bool cmpa (const na &a,const na &b) {return a.a<b.a;}
inline bool cmpc (const na &a,const na &b) {return a.c<b.c;}

inline bool check(int t,int x)
{
    return e[t][x].b>=mn&&e[t][x].b<=mx;
}

int main()
{
    n=read();A=read();B=read();C=read();
    for (int i=1;i<=n;i++)
    {
        e[0][i].a=read();
        e[0][i].b=read();
        e[0][i].c=e[0][i].a*A+e[0][i].b*B;
        e[1][i]=e[0][i];
    }
    sort(e[0]+1,e[0]+n+1,cmpa);
    sort(e[1]+1,e[1]+n+1,cmpc);
    for (int i=1;i<=n;i++)
    {
        mn=e[0][i].b;mx=mn+C/B;
        int l=0,r=0,cnt=0;
        for (int j=1;j<=n;j++)
        {
            while (r<n&&e[1][r+1].c-e[0][j].a*A-e[0][i].b*B<=C) cnt+=check(1,++r);//就是括号里面那个式子
            while (l<n&&e[0][l+1].a<e[0][j].a) cnt-=check(0,++l);
            ans=max(ans,cnt);
        }
    }
    printf("%d\n",ans);
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值