|
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int n,ans=1,l=1,r=2;
- struct times
- {
- int a,b;
- }t[1000001];
- bool operator < (times x,times y)
- {
- return x.b<y.b;
- }
- int main()
- {
- cin>>n;
- for(int i=1;i<=n;i++)cin>>t[i].a>>t[i].b;
- sort(t+1,t+n+1);
- while(r<=n)
- {
- if(t[r].a>=t[l].b)ans++,l=r;
- r++;
- }
- cout<<ans;
- return 0;
- }
复制代码 |
|