HDU1103 Flo's Restaurant 【模拟】

Flo‘s Restaurant

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 1112    Accepted Submission(s): 342

Problem Description

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.

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

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.

Sample Input

1 1 1
10:40 1
10:50 2
11:00 4
#
1 1 1
10:40 1
10:50 2
11:00 2
#
1 2 1
10:30 1
10:40 3
10:50 2
11:00 1
11:20 5
#
0 0 0

Sample Output

7
3
12

每次找到对应类型的桌子的最早撤离桌,并更新撤离时间。

#include <stdio.h>
#include <string.h>
#include <algorithm>
using std::min_element;
char str[10];
int ar[101], br[101], cr[101];

int main(){
	int a, b, c, h, m, num, table, count, *p;
	while(scanf("%d%d%d", &a, &b, &c), a || b || c){
		memset(ar, 0, sizeof(ar));
		memset(br, 0, sizeof(br));
		memset(cr, 0, sizeof(cr));
		count = 0;
		while(scanf("%s", str), str[0] != ‘#‘){
			sscanf(str, "%d:%d", &h, &m);
			m += h * 60;
			scanf("%d", &num);
			table = num;
			if(num & 1) ++table;
			if(table == 2){
				p = min_element(ar, ar + a);
				if(*p <= m + 30){
					if(*p <= m) *p = m + 30;
					else *p += 30;
					count += num;
				}
			}else if(table == 4){
				p = min_element(br, br + b);
				if(*p <= m + 30){
					if(*p <= m) *p = m + 30;
					else *p += 30;
					count += num;
				}
			}else{
				p = min_element(cr, cr + c);
				if(*p <= m + 30){
					if(*p <= m) *p = m + 30;
					else *p += 30;
					count += num;
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

HDU1103 Flo's Restaurant 【模拟】,布布扣,bubuko.com

HDU1103 Flo's Restaurant 【模拟】

时间: 2024-12-19 15:51:08

HDU1103 Flo's Restaurant 【模拟】的相关文章

POJ 2424 Flo&#39;s Restaurant 模拟

Flo's Restaurant Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2923   Accepted: 916 Description 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 s

【模拟】Flo&#39;s Restaurant

[poj2424]Flo's Restaurant Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2960   Accepted: 929 Description Sick and tired of pushing paper in the dreary bleary-eyed world of finance, Flo ditched her desk job and built her own restaurant.

HDU ACM 1103 Flo&#39;s Restaurant

分析:借助STL的min_element实现.每次更新最先被占用的桌子,具体见注释. #include<iostream> #include<algorithm> using namespace std; int main() { int A,B,C; char s[10]; int a[102],b[102],c[102]; int curtime,count,ans; int *p; //桌子最先空闲时间 while(cin>>A>>B>>C

hdu4883 TIANKENG’s restaurant 模拟下就好了

TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 102    Accepted Submission(s): 45 Problem Description TIANKENG manages a restaurant after graduating from ZCMU, and tens o

HDU4072Working at the Restaurant(模拟)

Working at the Restaurant Description Last night, Tom went on a date with a really nice girl. However, he forgot to take his credit card with him and he had no cash in his wallet, so he ended up working at the restaurant to pay for the bill. His task

HDU 4883 TIANKENG’s restaurant(模拟)

题意  天坑开了个饭店  他知道所有客人的进来时间和出去的时间  求天坑至少准备多少张凳子 以分钟为单位 直接模拟就行了   peo[i]代表第i分钟的人  第i组人第si分钟进来 第so分钟出去  那么j从si到so  peo[j]都加上这组的人数  最后看第几分钟人最多就是答案了 #include<cstdio> #include<cstring> using namespace std; const int N = 1441; int hi, ho, mi, mo, si,

DP题目列表/弟屁专题

声明: 1.这份列表不是我原创的,放到这里便于自己浏览和查找题目. ※最近更新:Poj斜率优化题目 1180,2018,3709 列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740, 1742, 1887, 1926, 1936, 195

[转] POJ DP问题

列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740, 1742, 1887, 1926, 1936, 1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029, 2039, 2063, 20

HDU 4883 TIANKENG’s restaurant Bestcoder 2-1(模拟)

TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description TIANKENG manages a restaurant after graduating from ZCMU, and tens of t