TIANKENG’s restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1622 Accepted Submission(s): 583
Problem Description
TIANKENG manages a restaurant after graduating from ZCMU, and tens of thousands of customers come to have meal because of its delicious dishes. Today n groups of customers come to enjoy their meal, and there are Xi persons in the ith group in sum. Assuming that each customer can own only one chair. Now we know the arriving time STi and departure time EDi of each group. Could you help TIANKENG calculate the minimum chairs he needs to prepare so that every customer can take a seat when arriving 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 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.
Output
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
Sample Input
Sample Output
题目分析:开始自己写的代码一直wa不知道怎么回事,后来听大神讲了一下,好像明白了,就是说如果第一组客人走后这些个椅子可以已给下一波用也可以给下下一波用,
那么我这个代码就出问题了,我这个代码是比较下一个区间和上一个区间是否相交或覆盖。也就是这种情况: 第一波来了6人吃完走了,第二波5人来了,没吃完呢,第三波5人来了。如果是这个代码结果就是 11 了。但是事实上结果应该是 10的。想一想是不是。
看这个代码也是暴力模拟解法也没超时,不过我感觉已经很巧妙了