标签:put blog main tput print ret text def 区间
3 1 5 2 3 3 6
2
#include "bits/stdc++.h" using namespace std; #define rep(i, s, n) for(int i=s;i<n;i++) const int N=10010; struct se{ int s,e; }arr[N]; bool cmp(struct se &a,struct se & b){ return a.e<b.e; } int main() { int n; while(~scanf("%d",&n)){ rep(i,0,n) scanf("%d%d",&arr[i].s,&arr[i].e); sort(arr,arr+n,cmp); int cnt=0; if(n>0) { cnt=1; int tmp=arr[0].e; rep(i,0,n){ if(arr[i].s>=tmp){ cnt++; tmp=arr[i].e; } } } printf("%d\n",cnt); } return 0; }
标签:put blog main tput print ret text def 区间
原文地址:http://www.cnblogs.com/kimsimple/p/7633718.html