forked from marioyc/Online-Judge-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2008 - Moo University - Team Tryouts.cpp
69 lines (49 loc) · 1.3 KB
/
2008 - Moo University - Team Tryouts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
struct cow{
int h,w,val;
cow(){}
}a[1000];
bool cmp1(cow x, cow y){
return x.val < y.val;
}
int main(){
int N,A,B,C;
scanf("%d %d %d %d",&N,&A,&B,&C);
int h[N],w[N];
for(int i = 0;i < N;++i){
scanf("%d %d",&a[i].h,&a[i].w);
a[i].val = A * a[i].h + B * a[i].w - C;
h[i] = a[i].h;
w[i] = a[i].w;
}
sort(a,a + N,cmp1);
sort(h,h + N);
int M1 = unique(h,h + N) - h;
sort(w,w + N);
int M2 = unique(w,w + N) - w;
int ans = 0;
for(int i = 0;i < M1;++i){
int pos1 = 0,aux = 0;
priority_queue<int, vector<int>, greater<int> > Q;
for(int j = 0,pos2 = 0;j < M2;++j){
int maxval = A * h[i] + B * w[j];
while(pos1 < N && a[pos1].val <= maxval){
if(a[pos1].h >= h[i]){
Q.push(a[pos1].w);
++aux;
}
++pos1;
}
while(!Q.empty() && Q.top() < w[j]){
Q.pop();
--aux;
}
ans = max(ans,aux);
}
}
printf("%d\n",ans);
return 0;
}