59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <algorithm>
|
|
|
|
using std::cin,std::cout,std::sort,std::max;
|
|
|
|
constexpr int MAX_N {(int)2e5+5};
|
|
struct City{
|
|
int a,b;
|
|
bool operator<(const City &that)const noexcept{
|
|
return this->a<that.a;
|
|
}
|
|
} city[MAX_N];
|
|
int n, len[MAX_N],ans;
|
|
|
|
template<class T>
|
|
class ReadNumber{
|
|
char c;
|
|
T w,n;
|
|
public:
|
|
ReadNumber& operator>>(T &num)noexcept{
|
|
c=(char)0,w=1,n=0;
|
|
while(!isdigit(c)){
|
|
// if constexpr(!std::is_same_v<ull, T>){
|
|
// if(c=='-')w=-1;
|
|
// }
|
|
c = getchar();
|
|
}
|
|
while(isdigit(c)){
|
|
n = n*10 + (c-'0');
|
|
c = getchar();
|
|
}
|
|
num = w*n;
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
ReadNumber<int> readint;
|
|
#define cin readint
|
|
|
|
int main(){
|
|
cin>>n;
|
|
for(int i=0;i<n;i++){
|
|
cin>>city[i].a>>city[i].b;
|
|
len[i]=1;
|
|
}
|
|
sort(city,city+n);
|
|
for(int i=0;i<n;i++){
|
|
for(int j=i-1;j>=0;j--){
|
|
if(city[j].b<city[i].b && len[i]<len[j]+1){
|
|
len[i]=len[j]+1;
|
|
}
|
|
}
|
|
}
|
|
for(int i=0;i<n;i++){
|
|
// cout<<"i:"<<i<<" "<<"len:"<<len[i]<<'\n';
|
|
ans = max(ans,len[i]);
|
|
}
|
|
cout<<ans<<'\n';
|
|
} |