[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的更多相关文章

  1. HDU 1103 Flo's Restaurant(模拟+优先队列)

    Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. Flo's Restaurant[HDU1103]

    Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. 九校模拟——餐馆(restaurant)

    1 餐馆(restaurant) 1.1 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 1.2 题目描述 共有n 种食材,一份食材i 需要花ti 小时不间断地进行播种,施肥 ...

  4. 别人整理的DP大全(转)

    动态规划 动态规划 容易: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...

  5. [转] POJ DP问题

    列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...

  6. poj动态规划列表

    [1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...

  7. POJ动态规划题目列表

    列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...

  8. POJ 动态规划题目列表

    ]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...

  9. DP题目列表/弟屁专题

    声明: 1.这份列表不是我原创的,放到这里便于自己浏览和查找题目. ※最近更新:Poj斜率优化题目 1180,2018,3709 列表一:经典题目题号:容易: 1018, 1050, 1083, 10 ...

随机推荐

  1. python初步学习-python数据类型-字典(dict)

    字典 字典类似于你通过联系人名字查找地址和联系人详细情况的地址簿,即,我们把键(名字)和值(详细情况)联系在一起.注意,键必须是唯一的,就像如果有两个人恰巧同名的话,你无法找到正确的信息. 注意,你只 ...

  2. python进行机器学习(四)之模型验证与参数选择

    一.模型验证 进行模型验证的一个重要目的是要选出一个最合适的模型,对于监督学习而言,我们希望模型对于未知数据的泛化能力强,所以就需要模型验证这一过程来体现不同的模型对于未知数据的表现效果. 这里我们将 ...

  3. Ubuntu安装pip

    首先打开终端 在终端输入:sudo apt-get install python-pip python-dev build-essential [+] 如果需要在Python3下安装pip,那么在py ...

  4. 在linux程序里面,知道一个函数地址,改函数是属于某个动态库的,怎么样得到这个动态库的全【转】

    转自:http://www.360doc.com/content/17/1012/11/48326749_694292472.shtml 另外dl_iterate_phdr可以查到当前进程所装在的所有 ...

  5. System V共享内存介绍

    (一)简单概念 共享内存作为一种进程间通信的方式,其相较于其他进程间通信方式而言最大的优点就是数据传输速率快.其内部实现的方式采用了Linux进程地址空间中的mmap文件映射区,将文件内容直接映射到各 ...

  6. Linux-进程间通信(五): 网络套接字

    不想说话,坑太深:持续学习网络编程中...

  7. UVALive 7040 Color

    题目链接:LA-7040 题意为用m种颜色给n个格子染色.问正好使用k种颜色的方案有多少. 首先很容易想到的是\( k * (k-1)^{n-1}\),这个算出来的是使用小于等于k种颜色给n个方格染色 ...

  8. iOS一个项目开始创建, 部署到git服务器

    在做iOS开发时, 最开始可能你的经理部署项目, 所以你不会插手, 只是直接从git上clone下来然后就开始撸码, 如果有一天你做经理了, 你怎么去部署一个项目呢, 下面我来过一遍流程 1. 首先需 ...

  9. git - 使用原理

    对git操作最大的功臣就是.git目录下的HEAD HEAD是什么 HEAD其实是一个类似于指针的东西,只不过这个指针的含义是指向当前的分支,当你再[ git checkout 分支 ] 的时候这个分 ...

  10. Dubbo之旅--注册中心

    在介绍Dubbo的内部逻辑的时候提到很多次注册中心的概念.实现注册中心的有很多,主要是以下四个注册中心分别是: Multicast注册中心 Zookeeper注册中心 Redis注册中心 Simple ...