Pagini recente » Cod sursa (job #3256991) | Cod sursa (job #391) | Cod sursa (job #2302418) | Cod sursa (job #2752996) | Cod sursa (job #1240762)
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
struct P{
int x,y;
};
vector<P> C1,C2,C3,C4;
int Q[50005];
struct comp{
bool operator()(const P &a,const P &b){
if(a.x == b.x) return a.y < b.y;
return a.x < b.x;
}
};
int Rez_cadran(vector<P> A){
int N = A.size();
sort(A.begin(),A.end(),comp());
int Best = 0;
for(int i = N - 1; i >= 0; i--){
Q[N-i] = INF;
int p = lower_bound(Q+1,Q+N-i+1,A[i].y) - Q;
Q[p] = A[i].y;
if(Best < p) Best = p;
}
return Best;
}
int main(){
freopen("pachete.in", "r", stdin);
freopen("pachete.out", "w", stdout);
int n,X,Y;
scanf("%d\n%d%d",&n,&X,&Y);
for(int i = 1; i <= n; i++){
P a;
scanf("%d%d",&a.x,&a.y);
if(a.x > X && a.y > Y){
C1.push_back(a);
}
else if(a.x < X && a.y > Y){
a.x = X - a.x + X;
C2.push_back(a);
}
else if(a.x < X && a.y < Y){
a.x = X - a.x + X;
a.y = Y - a.y + Y;
C3.push_back(a);
}
else{
a.y = Y - a.y + Y;
C4.push_back(a);
}
}
int Ans = 0,Ans1 = 0,Ans2 = 0,Ans3 = 0;
Ans += Rez_cadran(C1);
Ans1 += Rez_cadran(C2);
Ans2 += Rez_cadran(C3);
Ans3 += Rez_cadran(C4);
printf("%d\n",Ans+Ans1+Ans2+Ans3);
}