Tiankeng ' s RestaurantTime
limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)
Total submission (s): 1203 Accepted Submission (s): 505
Problem Descriptiontiankeng manages a restaurant after graduating from ZCMU, and tens of thousands of customers come to ha ve 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?
Inputthe 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.
Outputfor each test case, output the minimum number of chair that Tiankeng needs to prepare.
Sample Input
226 08:00 09:005 08:59 09:5,926 08:00 09:005 09:00 10:00
Sample Output
116#include <cstdio> #include <cstdlib> #include <cstring>using namespace Std;int time[25][60];int Main ( ) { int j,t,i,a,b,c,d,n,m,max,e; scanf ("%d", &t); while (t--) { memset (time,0,sizeof (time)); scanf ("%d", &n); while (n--) { scanf ("%d", &m); scanf ("%d:%d%d:%d", &a,&b,&c,&d); for (I=a+1;i<c;++i) for (j=0;j<60;++j) time[i][j]+=m; if (a==c) for (i=b;i<d;++i) time[a][i]+=m; else {for (i=b;i<60;++i) time[a][i]+=m; for (J=0;J<D;++J) time[c][j]+=m; } } max=0; for (I=0;i<23;++i) {for (j=0;j<60;++j) { if (Max<time[i][j]) max=time[i][j]; } } printf ("%d\n", max); } return 0;}
Hdoj Tiankeng ' s Restaurant