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
| const int MAX=5000+10; int ans=0,n,f; pair<int,int >p[MAX],s[MAX]; int cmp(pair<int,int > x,pair<int,int > y){ if(x.first == y.first) return x.second > y.second; return x.first > y.first; } int main(){ freopen("in","r",stdin); sf(n); fi(i,0,n){ sf(p[i].first);sf(p[i].second); } sort(p,p+n,cmp); fi(i,0,n){ f=0; fi(j,0,ans){ if(s[j].first>=p[i].first && s[j].second>=p[i].second){ s[j].first=p[i].first;s[j].second=p[i].second; f=1;break; } } if(!f){ s[ans].first=p[i].first;s[ans].second=p[i].second; ans ++; } } pf(ans); return 0; }
|