提交时间:2024-04-04 17:36:48

运行 ID: 141437

#include <bits/stdc++.h> using namespace std; struct node { int x , y ; void rd ( ) { cin >> x >> y ; } } s [100005] ; int stk [100001] = { 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 , s + p , 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 , stk + lgt , s [i] . y ) - stk ; stk [j] = s [i] . y ; } } cout << lgt << endl ; return 0; }