Sick and tired of pushing paper in the dreary bleary-eyed world of finance, Flo ditched her desk job and built her own restaurant.In the small restaurant, there are several two-seat tables, four-seat tables and six-seat tables. A single diner 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 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 arrival group waiting for the same kind of tables. 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, please calculate how many diners take their food in Flo’s restaurant. You may assume it takes half an hour for every diner from taking a seat to leaving the restaurant.
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 >0, A + B + C <= 100), which are the number of two-seat tables, the number of four-seat tables and the number of 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 < N <= 6), representing the arrival time and the number of diners of each group. The arrival 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 arrival 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.
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.
翻译:
厌倦了在沉闷的金融世界里推纸,Flo放弃了她的办公桌工作,建立了自己的餐厅。在小餐厅里,有几张两人桌、四人桌和六人桌。单人或两人一组安排两人座,三四人一组安排四人桌,五六人一组安排六人桌。Flo的餐厅提供美味的食物,很多人喜欢在这里用餐。每天午饭时间到了,餐厅里通常都坐满了食客。如果没有适合新来的用餐者的餐桌,他们必须等到有合适的餐桌空闲,并且没有更早到达的人群在等待同类型的餐桌。善良的Flo会告诉他们多久才能坐到,如果超过半小时,他们就会离开去另一家餐厅。现在给定一天来的食客名单,请计算有多少食客在Flo的餐厅用餐。你可以假设每位用餐者从入座到离开餐厅需要半小时。
有几个测试用例。每个测试用例的第一行包含由空格分隔的正整数,A,B和C(A,B,C>0,A + B + C <= 100),它们是双人桌的数量,四人桌的数量和六人桌的数量。从第二行开始,是来餐厅的食客列表,每行包含两个整数T和N(0 < N <= 6),分别表示到达时间和每组食客的人数。到达时间 T 用 HH:MM 表示,固定在 08:00 到 22:00 之间(餐厅在 23:00 关闭)。该列表按每个组的到达时间升序排序,你可以假设没有组同时到达。每个测试用例都以“#”行结束。以A = B = C = 0 的测试用例结束输入,不会处理。
对于每个测试用例,你应该在单独的一行中输出一个整数,即在 Flo 餐厅取餐的用餐者总数。