【牛客算法竞赛入门课第二节例题、习题】Laptop
Laptop
http://www.nowcoder.com/questionTerminal/9c36550065f542f88d1b05694ff138ed
#include <cstdio> #include <algorithm> using namespace std; const int N = 1e5 + 10; pair<int,int> a[N]; int n; int main(){ scanf("%d",&n); for(int i = 1;i <= n;i++){ scanf("%d%d",&a[i].first,&a[i].second); } sort(a+1,a+1+n); int mx = 0; int ans = 0; for(int i = n;i > 0;i--){ if(a[i].second < mx) ans++; mx = max(a[i].second,mx); } printf("%d\n",ans); return 0; }