10年福州水题
暴力+贪心
每5分钟取一次
枚举0,1,2,3,4 起点
然后爆搜所有区间,取右区间最小的
#include "stdio.h"
#include "string.h"
#include "string.h"
#include "math.h"
struct comp
{
int s,e;
} data[1010];
int main()
{
int n,i,j,l,k,min,sum,ans;
int hash[1010];
while (scanf("%d",&n)!=EOF)
{
if (n==0) break;
for (i=1;i<=n;i++)
scanf("%d%d",&data[i].s,&data[i].e);
ans=-1;
for (j=0;j<=4;j++)
{
sum=0;
memset(hash,0,sizeof(hash));
for (i=j;i<=1000;i+=5)
{
min=1010;
for (l=1;l<=n;l++)
if (data[l].s<=i && data[l].e>i && data[l].e<min && hash[l]==0)
{
min=data[l].e;
k=l;
}
if (min!=1010)
{
sum++;
hash[k]=1;
}
}
if (sum>ans) ans=sum;
}
printf("%d\n",ans);
}
return 0;
}