提交时间:2024-04-02 13:59:42
运行 ID: 141144
# include <bits/stdc++.h> using namespace std ; int dp [5005] , n ; struct nde { int x , y ; void rd ( ) { cin >> x >> y ; } } p [5005] ; bool cmp ( nde a , nde b ) { return a . x < b . x ; } int main ( ) { cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { p [i] . rd ( ) ; } sort ( p + 1 , p + n + 1 , cmp ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( p [i] . y > p [j] . y ) { dp [i] = max ( dp [i] , dp [j] + 1) ; } } } sort ( dp + 1 , dp + n + 1 , greater <int> ( ) ) ; cout << dp [1] << endl ; }