Tiankeng ' s restaurant
Time limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)
Total submission (s): 2559 Accepted Submission (s): 951
Problem Description Tiankeng manages a restaurant after graduating by ZCMU, and tens of thousands of customers come to H Ave meal because of its delicious dishes. Today n Groups of customers come to enjoy their meal, and there is Xi persons in the ith group in sum. Assuming that all customer can own only one chair. Now we know the arriving time STi and departure time EDi for each group. Could Tiankeng Calculate the minimum chairs he needs to prepare so that every customer can take a seat when Arriv ing the restaurant?
Input The first line contains a positive integer T (t<=100), standing for T test cases in all.
Each cases has a positive integer n (1<=n<=10000), which means n groups of customer. Then following n lines, each line there was 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& LT;60), Given that the arriving time must be earlier than the departure time.
Pay attention if a group of people arrive at the restaurant as soon as a group of people leaves from the restaurant , then the arriving group can is arranged to take their seats if the seats is enough.
Output for each test case, output the minimum number of chair that Tiankeng needs to prepare.
Sample Input
2 2 6 08:00 09:00 5 08:59 09:59 2 6 08:00 09:00 5 09:00 10:00
Sample Output
11 6
Source Bestcoder Round #2
Recommend Liuyiding | We have carefully selected several similar problems for you:5746 5745 5744 5743 5742
Main topic:
Give you a T-batch of guests, each batch of n guests, give each batch of guests to the time period, and each guest must have a stool, ask the hotel at least how many stool to prepare.
Problem Solving Ideas:
Turn the time into an array interval, add the number of people to the interval, and then find the number of people with the highest number of points.
The code is as follows:
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
BOOL CMP (int a,int b)
{
return a>b;
}
int main ()
{
int t;
scanf ("%d", &t);
while (t--)
{
int group;
int a[1450];
memset (A,0,sizeof (a));
scanf ("%d", &group);
for (int i=0;i<group;i++)
{
int people,t1,t2,t3,t4;
scanf ("%d%d:%d%d:%d", &people,&t1,&t2,&t3,&t4);
int s=t1*60+t2;
int e=t3*60+t4;
for (int j=s+1;j<=e;j++)
{
a[j]=a[j]+people;
}
}
Sort (a,a+1450,cmp);
printf ("%d\n", A[0]);
}
return 0;
}