Pagini recente » Monitorul de evaluare | Statistici Diaconu Diana (dianna) | Profil PiciuOlimpic | Cod sursa (job #2045896) | Cod sursa (job #2553584)
#include <bits/stdc++.h>
using namespace std;
ifstream in("pachete.in");
ofstream out("pachete.out");
int solve(vector< pair<int,int> > v)
{
sort(v.begin(),v.end());
vector<int> last;
last.push_back(0);
int nr = 0;
for (auto it: v)
{
int st = 1, dr = last.size()-1;
while (st<=dr)
{
int mj = (st+dr)/2;
if (last[mj]<it.second)
dr = mj-1;
else
st = mj+1;
}
if (st == (int)last.size())
{
nr++;
last.push_back(it.second);
}
else
last[st] = it.second;
}
return nr;
}
int main()
{
ios::sync_with_stdio(0);
int n,sx,sy;
vector<pair<int,int>> v1,v2,v3,v4;
in >> n >> sx >> sy;
for (int i = 1; i<=n; i++)
{
int x,y;
in >> x >> y;
x-=sx; y-=sy;
if (!x || !y)
continue;
if (x<0)
{
if (y<0)
v1.push_back({-x,-y});
else
v2.push_back({-x,y});
}
else
{
if (y<0)
v3.push_back({x,-y});
else
v4.push_back({x,y});
}
}
int ans = 0;
ans+=solve(v1); ans+=solve(v2); ans+=solve(v3); ans+=solve(v4);
out << ans;
}