hdu 3650 Hot Expo 活动安排 共多少天能参观完

Hot Expo

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

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.
 

 

Output
Output the minimum days that Sunny should spend in visiting in a seperated line for each test case.
 

 

Sample Input
  
  
2 1 4 4 5 2 2 3 4 6 0
 

 

Sample Output
  
  
2 1
#include <iostream>
#include<cstdio>
using namespace std;
int l[86405];
int main()
{
int n,p,q,i,j,tmp;
while(cin >> n)
{
   if(n == 0) break;
   memset(l,0,sizeof(l));
   for(i = 0; i < n; i++)
   {
    scanf("%d %d",&p,&q);
    if(p > q)
     tmp = p, p = q, q = tmp;
    for(j = p; j <= q; j++)
    {
     l[j]++;
    }
   }
   tmp = -1;
   for(i = 0; i < 86405; i++)
   {
    if(l[i] > tmp)
     tmp = l[i];
   }
   printf("%d/n",tmp);
}
return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值