我再也不想再打这种题目了……
自己打第一次 吃屎~
第二次参考了 吃屎~
第三次才对了,好烦~……
这个就是 类似单调队列的思维啦
枚举Min high和 Min Speed
然后选一遍就够了。
提交传送门
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
struct node{
LL x,y,sum;
}a[51000],b[51000];
LL A,B,C,ans;
int n;
int cmpx(const void *xx,const void *yy){
node n1=*(node*)xx;
node n2=*(node*)yy;
return n1.x-n2.x;
}
int cmpsum(const void *xx,const void *yy){
node n1=*(node*)xx;
node n2=*(node*)yy;
return n1.sum-n2.sum;
}
typedef long long LL;
int main(){
int n;scanf("%d%lld%lld%lld",&n,&A,&B,&C);
for(int i=1;i<=n;i++){
scanf("%lld%lld",&a[i].x,&a[i].y);
a[i].sum=A*a[i].x+B*a[i].y;
b[i]=a[i];
}
qsort(a+1,n,sizeof(node),cmpx);
qsort(b+1,n,sizeof(node),cmpsum);
int ans=0;
for(int i=1;i<=n;i++){
LL low2=a[i].y,high=low2+C/B,l=0,r=0;
int sum=0;
for(int j=1;j<=n;j++){
LL low1=a[j].x;
while(r<n&&b[r+1].sum<=A*low1+B*low2+C){
r++;if(b[r].y<=high&&b[r].y>=low2)sum++;
}
while(l<n&&a[l+1].x<low1){
l++;if(a[l].y<=high&&a[l].y>=low2)sum--;
}
ans=max(ans,sum);
}
}
printf("%d\n",ans);
return 0;
}