Pagini recente » Cod sursa (job #1216527) | Cod sursa (job #1058638) | Cod sursa (job #342569) | Cod sursa (job #55460) | Cod sursa (job #1147352)
#include<stdio.h>
#include<set>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define nmax 50005
struct punct{int x,y;};
int n, i, poz, rez, x, ne[5];
punct v[5][nmax];
set <int> h;
set <int> ::iterator it;
punct p,o;
bool cmp(punct a, punct b)
{ return (a.y<b.y); }
void citire()
{
scanf("%ld",&n);
scanf("%ld %ld",&o.x,&o.y);
for (i=1;i<=n;i++)
{
scanf("%ld %ld",&p.x,&p.y);
poz=2*(p.x>o.x)+(p.y>o.y);
p.x=abs(p.x-o.x); p.y=abs(p.y-o.y);
v[poz][++ne[poz]]=p;
}
}
void rezolvare()
{
sort(v[poz]+1,v[poz]+1+ne[poz],cmp);
h.clear();
for (i=1;i<=ne[poz];i++)
{
x=v[poz][i].x;
it=h.upper_bound(x);
if (it==h.begin())
rez++;
else
{
it--;
h.erase(it);
}
h.insert(x);
}
}
int main()
{
freopen("pachete.in","r",stdin);
freopen("pachete.out","w",stdout);
citire();
for (poz=0;poz<=3;poz++)
rezolvare();
printf("%ld",rez);
return 0;
}