Tiankeng ' s restaurant--hdu4883

Source: Internet
Author: User

Tiankeng ' s Restaurant

Time limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)
Total submission (s): 1629 Accepted Submission (s): 588


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 Input226 08:00 09:005 08:59 09:5,926 08:00 09:005 09:00 10:00

Sample Output11 6

The main idea of this problem is to find out the maximum number of overlapping time intervals!! Simple code, greedy thinking

1#include <stdio.h>2#include <string.h>3 intMain ()4 {5     intn,i,n,j,time[10010],a,b,c,d,e;6scanf"%d",&N);7      while(n--)8     {9         intBb,ee,max;Tenmemset (Time,0,sizeof(time)); Onescanf"%d",&n); Amax=0; -          for(i=0; i<n;i++) -         { thescanf"%d%d:%d%d:%d",&a,&b,&c,&d,&e); -bb=b* -+C; -ee=d* -+e; -                  for(j=bb;j<ee;j++) +time[j]+=a;//overlap Area number of people added -         } +          for(i=0;i< -* -; i++) AMax=max>time[i]?Max:time[i]; atprintf"%d\n", max); -     } -     return 0; -}

Tiankeng ' s restaurant--hdu4883

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.