提交时间:2024-08-01 17:11:51
运行 ID: 160060
# 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 . s < b . s ; } 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] . s < cur ) { ans ++ ; } else { cur = qu [i] . e ; } } cout << ans << endl ; return 0 ; }