hdu 3650 Hot Expo(贪心)
来源:互联网 发布:驴皮怎么熬制阿胶知乎 编辑:程序博客网 时间:2024/05/21 11:45
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3650
Problem Description
Sunny wants to go to the Shanghai Expo this month and he intends to visit n (1 <= n <= 100 ) country pavilions. As we all know, in each pavilion, there is always a wonderful performance every day. Every performance will always be played only one time each day. And performance i begins at beg[i] second and ends at end[i] second (0<=beg[i], end[i] <24 * 3600). Sunny can not visit more than one country pavilion at the same time. Sunny wouldn't like to miss any performance in the country pavilions that he plans to visit. However, it's also well known that getting accommodation in Shanghai is a little expensive, so he has to make a good arrangement to make his staying time (in days) there minimum.
Input
The input contains several test cases. Each test case begins with an integer number n. Then n lines follow and each contains two integers representing the begin time and end time of the performance in the corresponding day.
Input is terminated by a value of zero (0) for n.
Input is terminated by a value of zero (0) for n.
Output
Output the minimum days that Sunny should spend in visiting in a seperated line for each test case.
Sample Input
21 44 522 34 60
Sample Output
2 1
Source
2010 Asia Regional Hangzhou Site —— Online Contest
题目意思:给你n个演出的起始时间st和结束时间en,要你求出最少需要多少天能看完全部的表演。。每一天都有相应的表演。
代码如下:
第一种:
#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;}
5 0
- hdu 3650 Hot Expo(贪心)
- hdu 3650 - Hot Expo(贪心)
- HDU 3650 Hot Expo(气球染色 , 贪心 )
- HDU 3650 Hot Expo
- hdu 3650 Hot Expo
- HDU:3650 Hot Expo
- hdu 3650 Hot Expo(TwoPointer)
- hdu 3650 Hot Expo(2010杭州网选题)
- HDU 3650 Hot Expo (数据比较小)
- HDU 3650 Hot Expo(线段覆盖==离散化)
- Hot Expo
- HDU3650 Hot Expo
- HDU 3691 Nubulsa Expo
- HDU 3691 Nubulsa Expo
- HDU 3691 Nubulsa Expo(SW算法求最小割)
- HDU 3691 Nubulsa Expo(全局最小割Stoer_Wagn)
- Hdu 3691 Nubulsa Expo(无向图最小割)
- HDU 3691 Nubulsa Expo(全局最小割)
- 呓磁濮为尖订主顺同槿炮不
- URAL 1743 Domino Sorting 排序 + 贪心
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- hdu 3650 Hot Expo(贪心)
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- 呓磁濮为尖订主顺同槿炮不
- hdu 2814 Interesting Fibonacci
- java中的static关键字
- hiho_KMP算法