POJ 2424 Flo's Restaurant(2,4,6桌排队模拟)
2017-07-21 11:11
337 查看
Flo's Restaurant
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
Sample Output
Source
PKU Monthly,Alcyone
题目大意:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2972 | Accepted: 936 |
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
题目大意:
一家餐厅有a 个两人桌, b 个四人桌, c 个六人桌, 如果一组组人来吃饭, 如果对应的桌子(1, 2人对应两人桌, 以此类推)满的话就等, 如果发现等待超过30分钟就走, 假设每桌人都吃30分钟, 问这家餐馆最终能够招待多少人。
解题思路:充着动规写这题,但其实是模拟
AC代码
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> using namespace std; int main() { int a, b, c; int x[101]; int y[101]; int z[101]; // freopen( "in.txt", "r", stdin ); while( cin >> a >> b >> c ) { if( !a && !b && !c ) break; memset( x, 0, sizeof( x ) ); memset( y, 0, sizeof( y ) ); memset( z, 0, sizeof( z ) ); string s; int sum = 0; while( cin >> s && s != "#" ) { int n; int time = ( ( s[0] - '0' ) * 10 + s[1] - '0' - 8 ) * 60 + (s[3] - '0') * 10 + s[4] - '0'; cin >> n; switch ( n ) { case 1: case 2: { sort( x, x+a ); // x记录的是所有同一编号桌子的客人的出来时间, x[0]为最早桌出来的时间 if( x[0] - time <= 30 ) { // 等的时间不超过30分钟才排队 sum += n; if( x[0] < time ) x[0] = time; //如果客人到达时发现所有桌都空, 则将客人到达的时间设定为最早桌进入的时间 x[0] += 30; // 最早桌出来的时间存入x[0] } break; } case 3: case 4: { sort( y, y+b ); if( y[0] - time <= 30 ) { sum += n; if( y[0] < time ) y[0] = time; y[0] += 30; } break; } case 5: case 6: { sort( z, z+c ); if( z[0] - time <= 30 ) { sum += n; if( z[0] < time ) z[0] = time; z[0] += 30; } break; } default: break; } } cout << sum << endl; } return 0; }
相关文章推荐
- 【HDU1103】【模拟】Flo's Restaurant 餐厅吃饭排桌子
- poj 2424 Flo's Restaurant
- POJ 1068 Parencodings 模拟-括号匹配
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- poj 3083 Children of the Candy Corn(bfs+dfs 数组模拟方向)
- 第7周项目5 排队看病模拟
- G - Shuffle'm Up POJ 3087 模拟洗牌的过程,算作暴力搜索也不为过
- poj1053 模拟
- POJ1338 Ugly Numbers 堆优化+模拟
- POJ --3045--Cow Acrobats(贪心模拟)
- poj 4001 Xiangqi 模拟 顺带关于模拟的一番吐槽
- POJ - 3087 Shuffle'm Up(模拟)
- poj_1611_直接模拟
- 【模拟】POJ_2706_Connect
- POJ 1835 大模拟
- HDU 1035 && poj 1573 Robot Motion【模拟】
- POJ 3652 Persistent Bits (位运算,模拟)
- poj 2996 Help Me with the Game(模拟)
- POJ 2886 Who Gets the Most Candies?(线段树、模拟)
- POJ 3989 A hard Aoshu problem (模拟)