Home > Back-end >  Hdu 1103
Hdu 1103

Time:09-16




Hdu + 1103
Sick and tired of pushing paper in the dreary bleary - eyed world of finance, Flo ditched its ehrs desk job and built its ehrs own restaurant.

In the small restaurant, there are several two - seat tables, four - seat tables and six - seat tables. A single like the or A group of two diners should be arranged to A two - seat table, A group of three or four diners should be arranged to A four - seat table, and A group of five or six diners should be arranged to A six - seat table.

Flo's restaurant serves delicious food, and many people like to eat here. Every day the when lunch time comes, the restaurant is usually full of diners. If there is no suitable table for a new "coming group of diners, they have to wait until some suitable table is free and there isn 't an earlier arrivals from group, waiting for the same kind of name kind Flo will tell them how long they will get their seat, and If it's longer than half an hour, they will leave for another restaurant.

Now given the list of "coming diners in a day, both please calculate how many diners take their food in Flo 's restaurant. You may assume it takes half an hour for every like the from taking a seat to brigade of the restaurant.




Input
There are several test cases. The first line of each case contains There positive integers separated by blanks, A, B and C (A, B, C & gt; 0, A + B + C & lt;=100), which are the number of two - seat tables, the number of four - seat tables and the number of the six - seat tables respectively. From the second line, there is a list of "coming groups of diners, each line of which contains two integers, T and N (0 & lt; N & lt;=6), representing the arrivals from time and the number of diners of each group. The concatenated time T is denoted by HH: MM, and fixed between 08:00 and 22:00 (the restaurant closes at 23:00). The list is sorted by the arrivals from the time of each group in an ascending order, and you may assume that no groups arrive at the same time. Each test case is ended by a line of "#".

A test case with A=B=C=0 ends the input, and should not be processed.




The Output
For each test case, you should output an integer, the total number of diners who take their food in Flo 's restaurant, in a separated line.




The Sample Input
1 1 1
10:40:1
He, 2
11 4
#
1 1 1
10:40:1
He, 2
11 2
#
1 2 1
At 10:30 1
10:40:3
He, 2
11 1
5 loathsome
#
0 0 0






The Sample Output
7
3
12

My code
#include
using namespace std;
Int main () {
Int a, b, c;
While (cin> a> B> C& & a!=0 & amp; & b!=0 & amp; & C!!!=0) {
Char t [6].
Int d=0, j [a], [b], k, l [c], t1 [a], t2 [b], t3 [c], x=a, y=b, z=c, I=0;

for(i=0; iJ [I]=0;
for(i=0; i[I] k=0;
for(i=0; iL [I]=0;
for(i=0; iT1 [I]=1;
for(i=0; iT2 [I]=1;
for(i=0; iT3 [I]=1;
While (cin> T& & T [0]!='#') {
Int n, m, s, q;
Cin> n;
M=[0] - '0' (t) * 10 + t [1] - '0';
S=(t [3] - '0') * 10 + t [4] - '0';
Q=m * 60 + s;
If (n<=2) {
for(i=0; iIf (j + 30 [I] <=q& & J [I]!=0) {
X++;
T1 [I]=1;
}}
If (x>=1) {
X -;
for(i=0; iIf (t1 [I]==1) {
J [I]=q;
T1 [I]=0;
D +=n;
break; }}}
The else {
for(i=0; iIf (j [I] [I] + j=30;
D +=n;
break; }}}}
Else if (n> 2 & amp; & n<{
=4)for(i=0; iIf (k + 30 [I] <=q& & K [I]!=0) {
Y++;
T2 [I]=1; }}
If (y>=1) {
Y -;
for(i=0; iIf (t2 [I]==1) {
[I] k=q;
T2 [I]=0;
break; }}
D +=n;
}
The else {
for(i=0; iIf (k [I] [I] + k=30;
D +=n;
break; }}}}
The else {
for(i=0; iIf (l + 30 [I] <=q& & L [I]!=0) {
Z++;
T3 [I]=1; }}
If (z>=1) {
Z -;
for(i=0; iIf (t3 [I]==1) {
L=q [I];
T3 [I]=0;
break; }}
D +=n;
}
The else {
for(i=0; iIf (l [I] L [I] +=30;
D +=n;
break; }}}}
}
Cout<& lt; D<& lt; Endl;
}
return 0;
}

For bosses to check wrong, mainly is the restaurant have to wait 30 minutes when there is no empty table is also added
  • Related