TIANKENG’s restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1629 Accepted Submission(s): 588
Each cases has a positive integer n(1<=n<=10000), which means n groups of customer. Then following n lines, each line there is a positive integer Xi(1<=Xi<=100), referring to the sum of the number of the ith group people, and the arriving time STi and departure time Edi(the time format is hh:mm, 0<=hh<24, 0<=mm<60), Given that the arriving time must be earlier than the departure time.
Pay attention that when a group of people arrive at the restaurant as soon as a group of people leaves from the restaurant, then the arriving group can be arranged to take their seats if the seats are enough.
2
6 08:00 09:00
5 08:59 09:59
2
6 08:00 09:00
5 09:00 10:00
这个题主要思想时,找出重叠时间区间的最大人数!!简单代码,贪心思想
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,N,j,time[],a,b,c,d,e;
scanf("%d",&N);
while(N--)
{
int bb,ee,max;
memset(time,,sizeof(time));
scanf("%d",&n);
max=;
for(i=;i<n;i++)
{
scanf("%d%d:%d%d:%d",&a,&b,&c,&d,&e);
bb=b*+c;
ee=d*+e;
for(j=bb;j<ee;j++)
time[j]+=a;//重叠区域相加人数
}
for(i=;i<*;i++)
max=max>time[i]?max:time[i];
printf("%d\n",max);
}
return ;
}