标签:
[2016-02-04][HDU][2037][今年暑假不AC]| Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
12 1 3 3 4 0 7 3 8 15 19 15 20 10 15 8 18 6 12 5 10 4 14 2 9 0
Sample Output
5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include<cstdio>#include<algorithm>using namespace std;const int maxn = 100 + 10;struct room{ int s,e; bool operator < (const room a)const { return e < a.e || (e == a.e && s > a.s); } }r[maxn];int main(){ int n; while(~scanf("%d",&n) && n ){ for(int i = 0;i < n ;i++){ scanf("%d%d",&r[i].s,&r[i].e); } sort(r,r+n); room pre = r[0]; int res = 1; for(int i = 1; i < n;i++){ if(r[i].s >= pre.e){ res++; pre = r[i]; } } printf("%d\n",res); } return 0;} |
[2016-02-04][HDU][2037][今年暑假不AC]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5182349.html