化式子,然后两个指针平(A)过去
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#define R(a,b,c) for(register int a = (b); a <= (c); ++a)
#define nR(a,b,c) for(register int a = (b); a >= (c); --a)
#define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
#define MP make_pair
#ifdef QWQ
#define D_e_Line printf("
------
")
#define D_e(x) cerr << (#x) << " " << x << endl
#define C_e(x) cout << (#x) << " " << x << endl
#define FileOpen() freopen("in.txt", "r", stdin)
#define FileSave() freopen("out.txt", "w", stdout)
#define Pause() system("pause")
#include <cassert>
#define PASS fprintf(stderr, "Passing [%s] in LINE %d
",__FUNCTION__,__LINE__)
#else
#define D_e_Line
#define D_e(x)
#define C_e(x)
#define FileOpen()
#define FileSave()
#define Pause()
#define PASS
#endif
using namespace std;
struct FastIO {
template<typename ATP> inline FastIO& operator >> (ATP &x) {
x = 0; int sign = 1; char c;
for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') sign = -1;
while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
if(sign == -1) x = -x;
return *this;
}
} io;
template<typename ATP> inline ATP Max(ATP x, ATP y) {
return x > y ? x : y;
}
template<typename ATP> inline ATP Min(ATP x, ATP y) {
return x < y ? x : y;
}
template<typename ATP> inline ATP Abs(ATP x) {
return x < 0 ? -x : x;
}
const int N = 5007;
#define int long long
struct nod {
int x, y, s;
// nod() {}
// nod(int _x, int _s) : x(_x), s(_s) {}
} x[N], y[N];
#undef int
int main() {
FileOpen();
#define int long long
int n, A, B, C;
io >> n >> A >> B >> C;
R(i,1,n){
io >> x[i].x >> x[i].y;
x[i].s = A * x[i].x + B * x[i].y;
y[i] = x[i];
}
sort(x + 1, x + n + 1, [&](const nod &a, const nod &b){ return a.x < b.x;});
sort(y + 1, y + n + 1, [&](const nod &a, const nod &b){ return a.s < b.s;});
int ans = 0;
R(i,1,n){
int minY = x[i].y, maxY = x[i].y + C / B;
int l = 1, r = 0, tot = 0;
R(j,1,n){
int minX = x[j].x, Smax = minX * A + minY * B + C;
while(r < n && y[r + 1].s <= Smax){
++r;
if(minY <= y[r].y && y[r].y <= maxY) ++tot;
}
while(l <= n && x[l].x < minX){
if(minY <= x[l].y && x[l].y <= maxY) --tot;
++l;
}
ans = Max(ans, tot);
}
}
printf("%lld", ans);
return 0;
}