[ACM] HDU 4883 Tiankeng ' s Restaurant

Source: Internet
Author: User

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 customers come to has 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?


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 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.


Output

For each test case, the output of the minimum number of chair is 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


Source

Bestcoder Round #2

Problem Solving Ideas:

Test instructions: There are n groups of guests to eat, give the number of guests per group and meal start time, end time, in the form of hh:mm; Ask a group of guests to be seated when they come.
, ask at least how many chairs are needed to do it (a guest needs a chair).

Time[i], which represents the number of people who dine in the first minute, that is, how many chairs are needed, the start time, and the time to convert the end time to minutes.
Note that the end of a set of boundaries and the start of another group, if the same, does not require additional chairs, so the end time for each group is-1. For each group of people, the start time to the end time
The number of people circulating time[i]+= the group. The last iteration of the Time[i] array, where the maximum value is found, is the answer to the question.

Code:

#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include < stdlib.h> #include <cmath> #include <iomanip> #include <vector> #include <set> #include < map> #include <stack> #include <queue> #include <cctype>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", &AMP;SH,&AMP;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<time[i]) ans=time[i]; }        printf ("%d\n", ans); } return 0;}


[ACM] HDU 4883 Tiankeng ' s Restaurant

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.