提交时间:2024-04-05 16:30:26

运行 ID: 141508

# include <bits/stdc++.h> using namespace std ; struct node { int x , y ; void rd ( ) { cin >> x >> y ; } } s [100005] ; int stk [100001] = { int ( 1e-9 ) } ; bool cmp ( node a , node b ) { return ( a . x == b . x ? a . y < b . y : a . x < b . x ) ; } int main() { int n , m , p , lgt = 0 ; cin >> n >> m >> p ; for ( int i = 1 ; i <= p ; i ++ ) { s [i] . rd ( ) ; } sort ( s + 1 , s + p + 1 , cmp ) ; for ( int i = 1 ; i <= p ; i ++ ) { if ( s [i] . y > stk [lgt] ) { stk [++ lgt] = s [i] . y ; } else { int j = upper_bound ( stk + 1 , stk + lgt + 1 , s [i] . y ) - stk + 1 ; stk [j] = s [i] . y ; } } cout << lgt << endl ; return 0 ; }