Pagini recente » Cod sursa (job #400659) | Cod sursa (job #682954) | Cod sursa (job #696993) | Cod sursa (job #331732) | Cod sursa (job #1240774)
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
struct P{
long long x,y;
};
vector<P> C1,C2,C3,C4;
long long 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;
}
};
long long Rez_cadran(vector<P> A){
int N = A.size();
sort(A.begin(),A.end(),comp());
long long 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("%lld%lld",&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);
}
}
long long Ans = 0;
Ans += Rez_cadran(C1);
Ans += Rez_cadran(C2);
Ans += Rez_cadran(C3);
Ans += Rez_cadran(C4);
printf("%lld\n",Ans);
}