标签:
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <cstring> #include <stack> #include <queue> #include <algorithm> #include <cmath> #include <map> #define PI acos(-1.0) #define ms(a) memset(a,0,sizeof(a)) #define msp memset(mp,0,sizeof(mp)) #define msv memset(vis,0,sizeof(vis)) using namespace std; //#define LOCAL struct Node { int b; int e; }t; bool cmp(Node n1,Node n2) { if(n1.e==n2.e)return n1.b<n2.b; return n1.e<n2.e; } vector<Node> v; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); #endif // LOCAL ios::sync_with_stdio(false); int n; while(cin>>n&&n) { v.clear(); while(n--) { cin>>t.b>>t.e; v.push_back(t); } sort(v.begin(),v.end(),cmp); int ans=1; for(int i=1;i<v.size();i++) { t=v[i]; if(t.b>=v[i-1].e)ans++; else v.erase(v.begin()+i),i--; } printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/gpsx/p/5187004.html