提交时间:2024-08-01 17:12:27

运行 ID: 160061

# include <bits/stdc++.h> using namespace std ; struct qj { int b , e ; } a [40005] ; bool cmp ( qj a , qj b ) { return a . e != b . e ? a . e < b . e : a . b < b . b ; } int main ( ) { int n ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { cin>> a [i] . b >> a [i] . e ; } sort ( a + 1 , a + n + 1 , cmp ) ; int ans = 0 , cur = a [1] . e ; for ( int i = 2 ; i <= n ; i ++ ) { if ( qu [i] . b < cur ) { ans ++ ; } else { cur = qu [i] . e ; } } cout << ans << endl ; return 0 ; }