感谢Twilight_Sx的题解
按身高排序,枚举身高最小值,原式
[A imes(H-minh)+B imes(V-minv)le C\
A imes H+B imes V-Cle A imes minh+B imes minv
]
固定常量,令(S_x=A imes H_x-C-A imes minh)
[S_x+B imes V_xle B imes minv
]
移项可得
[V_x-minvle frac{-S_x}B
]
又因为
[V_xge minv
]
所以(frac{S_x}B+V_xle minv le V_x) ,
所以我们在(v)范围上差分,取最大值即可
int n,A,B,C,mx,ans,a[10005];
struct node{
int v,h;
friend bool operator < (const node &a,const node &b){
return a.h < b.h;
}
}p[N];
void work(int x){
int T = p[x].h * A;
for(int i = x;i <= n;++i){
int l = max(0,p[i].v - (T - A*p[i].h + C)/B);
int r = p[i].v;
if(l > r) continue;
++a[l]; --a[r+1];
}
for(int i = 0,tem = 0;i <= mx;++i){
a[i] += tem; tem = a[i];
ans = max(ans,a[i]); a[i] = 0;
}
}
int main(){
n = read(); A = read(); B = read(); C = read();
for(int i = 1;i <= n;++i){
p[i].h = read(); p[i].v = read();
mx = max(mx,p[i].v);
}
sort(p + 1,p + n + 1);
for(int i = n;i >= 1;--i) work(i);
printf("%d
",ans);
}