转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3650
----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋:http://user.qzone.qq.com/593830943/main
----------------------------------------------------------------------------------------------------------------------------------------------------------
2 1 4 4 5 2 2 3 4 6 0
2 1
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; struct Time { int s, e; int f; }a[117]; bool cmp(Time x, Time y) { if(x.s == y.s) return x.e < y.e; return x.s < y.s; } int main() { int n; int t, i, j, k, flag; while(scanf("%d",&n) && n) { for(i = 1; i <= n; i++) { scanf("%d %d",&a[i].s,&a[i].e); a[i].f = 0; } sort(a+1,a+n+1,cmp); int num, ans, td; num=n,ans=0; while(num) { ans++; td=-1; for(i = 1; i <= n; i++) { if(!a[i].f && a[i].s > td) { td=a[i].e; a[i].f = 1; num--; } } } printf("%d\n",ans); } return 0; }
#include<stdio.h> #include<string.h> int max(int a,int b) { return a>b?a:b; } int main() { int n; int c[3600*24+10]; int maxnum=3600*24,i,a,b; int maxx; while(scanf("%d",&n),n) { memset(c,0,sizeof(c)); while(n--) { scanf("%d%d",&a,&b); for(i=a;i<=b;i++) { c[i]++; } } maxx=c[0]; for(i=1;i<maxnum;i++) { maxx=max(maxx,c[i]); } printf("%d\n",maxx); } return 0; }
hdu 3650 Hot Expo(贪心),布布扣,bubuko.com
原文地址:http://blog.csdn.net/u012860063/article/details/38182843