[ACM] HDU 4883 TIANKENG's restaurant

Source: Internet
Author: User

[ACM] HDU 4883 TIANKENG's restaurant
TIANKENG's restaurant

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission (s): 931 Accepted Submission (s): 412


Problem Description

TIANKENG manages a restaurant after graduating from ZCMU, and tens of thousands of MERs come to have meal because of its delicious dishes. today n groups of MERs 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. cocould you help TIANKENG calcu Late 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

226 08:00 09:005 08:59 09:5926 08:00 09:005 09:00 10:00


Sample Output

116


Source

BestCoder Round #2

Solution:

N groups of guests are coming for dinner. The number of guests in each group and the meal start time are given. The end time is in the format of hh: mm; A group of guests must be assigned a seat when they come.
Ask how many chairs are required at least (a guest needs a Chair ).

Time [I] indicates the number of people dining at the I minute, that is, how many chairs are needed to convert the start time and end time into minutes.
Note that if the end of the boundary group is the same as the start of the other group, no additional chair is required. Therefore, the end time of each group is-1. for each group of people, the start time and End Time
Cycle time [I] + = number of people in this group. Finally, traverse the time [I] array and find the maximum value as the answer to this question.

Code:

#include 
 
  #include 
  
   #include #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         #include 
          
           #include 
           
            #include 
            
             using namespace std;#define ll long longint n;int time[1442];int main(){ int t; scanf("%d",&t); while(t--) { memset(time,0,sizeof(time)); scanf("%d",&n); int sh,sm; int eh,em; int cnt=0; int ans=0; for(int i=1;i<=n;i++) { scanf("%d",&cnt); scanf("%d:%d",&sh,&sm); scanf("%d:%d",&eh,&em); int s=sh*60+sm; int e=eh*60+em; e--; for(int i=s;i<=e;i++) { time[i]+=cnt; } } for(int i=0;i<1440;i++) { if(ans
             
              


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.