Tiankeng ' s RestaurantTime
limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)
Total submission (s): 1366 Accepted Submission (s): 546
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
At first thought is greedy, direct WA, and later read all the body, found that the problem of coverage, but the data is small, violence should be able to, tried a little naked violence, timed out, and then the violence to optimize a bit before.
Timeout code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace Std;int Main () { int T; scanf ("%d", &t); int str[11000]; while (t--) { int m; scanf ("%d", &m); int N, H1, M1, H2, M2, sum; memset (str, 0, sizeof (str)); sum = 0; while (m--) { scanf ("%d%d:%d%d:%d", &n, &h1, &m1, &H2, &m2); int time1 = H1 * + m1; int time2 = h2 * + m2; for (int i = time1; i < time2; ++i) { Str[i] + = n; sum = Max (str[i], sum); } } printf ("%d\n", sum); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 4883--tiankeng ' s restaurant "range coverage && violence"