http://acm.hdu.edu.cn/showproblem.php?pid=3650
题意:给你N个活动的开始时间和结束时间,问你几天能看完,每天的同一时刻只能看一个节目。
线段覆盖。在一个数组上记录每个活动开始和结束的下一天。从开始到结束扫一遍,记录“重叠”最多的点。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const double eps=1e-8;
const double INF=1e50;
//const double pi=acos(-1);
#define N 86500
int a[N];
int main()
{
//freopen("a","r",stdin);
int i,n,p,q;
while (1)
{
scanf("%d",&n);
if (n==0) break;
for (i=0;i<N-5;i++) a[i]=0;
for (i=1;i<=n;i++)
{
scanf("%d%d",&p,&q);
q++;
a[p]+=1;
a[q]-=1;
}
int max=0,m=0;
for (i=0;i<N-5;i++)
{
m+=a[i];
if (m>max) max=m;
}
printf("%d\n",max);
}
return 0;
}