boolcmp( Node a, Node b ){ if( a.A != b.A ) return a.A < b.A; return a.B < b.B; }
intLDS( ){ vector<int> g; for( int i = 1; i <= n; ++ i ) { // 小 Trick: 求 B 的严格递减子序列 <=> 求 -B 的严格递增子序列 int x = -a[i].B; auto it = lower_bound( g.begin( ), g.end( ), x ); if( it == g.end( ) ) g.push_back( x ); else *it = x; } return g.size( ); }
voidsolve( ){ cin >> n; for( int i = 1; i <= n; ++ i ) { int t, x; cin >> t >> x; a[i] = { t - x, t + x }; } sort( a + 1, a + n + 1, cmp ); int res = LDS( ); cout << res << '\n'; }