TIANKENG’s restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1360 Accepted Submission(s): 545
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.
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 10010
using namespace std;
struct node
{
int come;
int go;
int peo;
}s[MAX];
int dp[MAX];
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int t,n,m,j,i;
int ha,hb,ma,mb;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(dp,0,sizeof(dp));
for(i=0;i<n;i++)
{
scanf("%d %d:%d %d:%d",&s[i].peo,&ha,&ma,&hb,&mb);
s[i].come=ha*60+ma;
s[i].go=hb*60+mb;
for(j=s[i].come;j<s[i].go;j++)
{
dp[j]+=s[i].peo;
}
}
sort(dp,dp+MAX,cmp);
printf("%d\n",dp[0]);
}
return 0;
}