杭电 1103 Flo's Restaurant
来源:互联网 发布:基站离线数据库 2017 编辑:程序博客网 时间:2024/05/14 19:12
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<iostream>#include<cstdio>#include<queue>#include<algorithm>#include<vector>#include<functional>using namespace std;int max(int a,int b){ return a>b?a:b;}int main(){ int a,b,c,t[3],h,m,e,d,n; int i; priority_queue<int,vector<int>,greater<int> > as[3]; char s[7]; while(scanf("%d%d%d",&a,&b,&c)==3&&a) { for (i=0;i<a;i++) as[0].push(0); //将 每种的桌子数 入队 for (i=0;i<b;i++) as[1].push(0); for (i=0;i<c;i++) as[2].push(0); t[0]=t[1]=t[2]=n=0; while(scanf("%s",s)==1&&s[0]!='#') { e=0; scanf("%d",&d); e=600*(s[0]-'0')+60*(s[1]-'0')+10*(s[3]-'0')+(s[4]-'0'); if(d==1||d==2) { if(!as[0].empty())//判断 对是否 为空 也就是 桌子数是不是为零 { if(as[0].top()<=e+30) //如果 刚来的时间在加30分钟的 大于队列中最先走的时间 可入队 { e=max(e,as[0].top()); //判断 时间大小 选择入队时间 如果 刚来的时间e大于 队列中最先走的时间 就 e+30 入队 if(e+30<=23*60) //判断是否在营业 { as[0].pop(); as[0].push(e+30); n+=d; } } } } else if(d==3||d==4)//同上 { if(!as[1].empty()) { if(as[1].top()<=e+30) { e=max(e,as[1].top()); if(e+30<=23*60) { as[1].pop(); as[1].push(e+30); n+=d; } } } } else { if(!as[2].empty()) { if(as[2].top()<=e+30) { e=max(e,as[2].top()); if(e+30<=23*60) { as[2].pop(); as[2].push(e+30); n+=d; } } } } } printf("%d\n",n); for(i=0;i<3;++i)//清空队列 while(!as[i].empty()) as[i].pop(); } return 0;}
简单代码 ~~(>_<)~~
#include<stdio.h>#include<iostream>#include<algorithm>#include<map>#include<queue>#include<stack>#include<vector>#include<cstdlib>#include<functional>using namespace std;int a, b, c, tot, t, sum, ans = 0;char s[20];int main(){ while (scanf("%d%d%d", &a, &b, &c), a + b + c) { ans = 0; priority_queue<int, vector<int>, greater<int> > p[3]; for (int i = 0; i < a; i++) p[0].push(0); for (int i = 0; i < b; i++) p[1].push(0); for (int i = 0; i < c; i++) p[2].push(0); while (scanf("%s", s), s[0] != '#') { t = 600 * s[0] + 60 * s[1] + 10 * s[3] + s[4] - '0' * 671; scanf("%d", &sum); tot = (sum - 1) / 2; if (!p[tot].empty()) { int q = p[tot].top(); if (q <= t + 30) { q = max(q, t) + 30; if (q <= 23 * 60) { p[tot].pop(); p[tot].push(q); ans += sum; } } } } printf("%d\n", ans); }}
- 杭电 1103 Flo's Restaurant
- HDU 1103 Flo's Restaurant
- HDU 1103 Flo's Restaurant
- 模拟 hdu 1103 Flo's Restaurant
- HDU ACM 1103 Flo's Restaurant
- Flo's Restaurant
- hdu 1103 flo restaurant
- poj 2424 Flo's Restaurant
- poj 2424 Flo's Restaurant
- HDU1103 Flo's Restaurant 【模拟】
- poj 2424 Flo's Restaurant
- poj 2424 Flo's Restaurant
- HDU 1103 Flo's Restaurant(模拟+优先队列)
- HDU杭电4883 TIANKENG’s restaurant
- 杭电4883TIANKENG’s restaurant
- 【杭电】[4883]TIANKENG’s restaurant
- 【杭电4883】TIANKENG’s restaurant
- 杭电-4883 TIANKENG’s restaurant
- 【MVC】Razor语法一
- STM32 CAN总线应用程序,调试通过仅供参考
- XMind思维导图教程——如何画好思维导图?(二)
- jenkins+maven+svn 自动化布署
- Deep Reinforcement Learning-based Image Captioning with Embedding Reward
- 杭电 1103 Flo's Restaurant
- java 重写equals()方法
- Spring @value 遇到的问题
- NYOJ 309 BOBSLEDDING(细节题)
- ORACLE 解锁
- 移动开发知识技能
- 面试题:有1、2、3、4四个数字,能组成多少个互不相同且一个数字中无重复数字的三位数,并把它们都输出。
- 如何还原系统?系统还原教程
- 5分钟了解MySQL5.7union all用法的黑科技