bzoj1071

来源:互联网 发布:域名转发 编辑:程序博客网 时间:2024/04/30 05:46

神奇的乱搞。。。被卡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;}


0 0