Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 931 Accepted Submission(s): 412
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?
The first line contains a positive integer T(T<=100), standing for T test cases in all.
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
2 2 6 08:00 09:00 5 08:59 09:59 2 6 08:00 09:00 5 09:00 10:00
11 6
BestCoder Round #2
解題思路:
題意為:有n組客人來吃飯,給出每組客人的人數及用餐開始時間,結束時間,格式為hh:mm;要求一組客人來的時候就必須給其安排位子
,問最少需要多少把椅子才能做到(一位客人需要一把椅子).
time[i],表示第i分鐘有多少用餐的人,也就是需要多少把椅子,將開始時間,結束時間轉化為分鐘為單位的時間。
注意邊界一組的結束和另一組的開始如果相同,則不需要額外的椅子,因此把每組的結束時間都-1. 對於每一組人,開始時間到結束時間
循環time[i]+=該組的人數。 最後再遍歷time[i]數組,從中找到最大值即為該題的答案。
代碼:
#include#include #include #include #include #include #include #include #include #include