【模拟】Flo'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.

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

Source

PKU Monthly,Alcyone

试题分析:简单模拟一下现在每个桌子最先走的就好了……

代码

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘;
    return x*f;
}
int A,B,C;
int le1[101],le2[101],le3[101];
int HH,MM,P;
int k[4];
char s[7];
int main(){
    k[1]=read(),k[2]=read(),k[3]=read();
    while(k[1]!=0||k[2]!=0||k[3]!=0){
        int res=0;
        memset(le1,0,sizeof(le1));
        memset(le2,0,sizeof(le2));
        memset(le3,0,sizeof(le3));
        while(1){
            cin>>s;
            if(s[0]==‘#‘) break;
            HH=0;
            int tmp=1,e=1;
            for(tmp=0;s[tmp]!=‘:‘;tmp++) ;
            for(int i=tmp-1;i>=0;i--)
                HH+=((s[i]-‘0‘)*e),e*=10;
            MM=0,e=1;
            for(int i=strlen(s)-1;i>tmp;i--) MM+=((s[i]-‘0‘)*e),e*=10;
            int T=(HH-7)*60+MM;
            //cout<<T<<endl;
			P=read();
            P++;
            if(P/2==1&&k[1]){
            	P--;
            	sort(le1,le1+k[1]);
            	if(le1[0]-T<=30){
            	//	cout<<"true"<<endl;
            		res+=P;
            		if(le1[0]>=T) le1[0]+=30;
					else le1[0]=T+30;
				}
			}
			else if(P/2==2&&k[2]){
				P--;
				sort(le2,le2+k[2]);
			    if(le2[0]-T<=30){
			    	//cout<<"true2"<<endl;
            		res+=P;
            		if(le2[0]>=T) le2[0]+=30;
					else le2[0]=T+30;
				}
			}
			else if(P/2==3&&k[3]){
				P--;
				sort(le3,le3+k[3]);
				if(le3[0]-T<=30){
					//cout<<"true3"<<endl;
            		res+=P;
            		if(le3[0]>=T) le3[0]+=30;
					else le3[0]=T+30;
				}
			}
        }
        printf("%d\n",res);
        k[1]=read(),k[2]=read(),k[3]=read();
    }
}
/*
1 3 2
09:45 3
09:46 5
09:59 4
10:00 1
10:01 3
10:20 3
10:30 2
11:20 5
11:40 1
12:00 3
12:10 2
14:20 5
15:00 3
15:20 6
15:40 5
17:30 2
19:00 6
19:40 4
20:03 4
20:05 4
21:40 2
21:44 1
22:00 1
#
*/

【模拟】Flo's Restaurant

时间: 2024-12-26 03:32:00

【模拟】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

HDU1103 Flo&#39;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 finan

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

九校模拟——餐馆(restaurant)

1 餐馆(restaurant) 1.1 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 1.2 题目描述 共有n 种食材,一份食材i 需要花ti 小时不间断地进行播种,施肥, 直至收获.当然,一份食材i 是可以直接卖掉得到wi 块钱的. 招牌菜共有m 种,一份招牌菜i 需要消耗一定的食材,花Ti 小时不 间断地来烹饪,叫卖,并最终卖出得到Wi 块钱. 整个季度换算下来一共有Tmax 小时可供你使用,铜企鹅需要在这期间 赚到最多的钱,这样他才有足够多的钱来steam 剁

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

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

NOIP模拟赛(2017.9.15) -餐厅(restaurant)

餐厅(restaurant) [问题描述] 小R最近在玩一款模拟餐厅打工的游戏,其中有一个叠盘子的小游戏小R很喜欢.这个小游戏是这样的:有一个放盘子的机器会在一条直线上运动,机器里装着n个盘子,其中第i个盘子半径为ri,并且如果要放下该盘子,盘子的中心必须放在直线上xi的位置上,小R可以决定放下哪些盘子和放下这些盘子的顺序,盘子可以放在空位上,或者叠在一个上面没有其他盘子的盘子上,但要求被叠的盘子必须包含要叠上去的盘子.小R想要让叠出的盘子尽量高,请你计算出最高的一叠最多能叠几个盘子. [输入格