【模拟】Flo's Restaurant
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2960 | Accepted: 929 |
Description
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
A test case with A = B = C = 0 ends the input, and should not be processed.
Output
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
#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的更多相关文章
- HDU 1103 Flo's Restaurant(模拟+优先队列)
Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Flo's Restaurant[HDU1103]
Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 九校模拟——餐馆(restaurant)
1 餐馆(restaurant) 1.1 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 1.2 题目描述 共有n 种食材,一份食材i 需要花ti 小时不间断地进行播种,施肥 ...
- 别人整理的DP大全(转)
动态规划 动态规划 容易: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...
- [转] POJ DP问题
列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...
- poj动态规划列表
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...
- POJ动态规划题目列表
列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...
- POJ 动态规划题目列表
]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...
- DP题目列表/弟屁专题
声明: 1.这份列表不是我原创的,放到这里便于自己浏览和查找题目. ※最近更新:Poj斜率优化题目 1180,2018,3709 列表一:经典题目题号:容易: 1018, 1050, 1083, 10 ...
随机推荐
- Vuejs - 单文件组件
为什么需要单文件组件 在之前的实例中,我们都是通过 Vue.component 或者 components 属性的方式来定义组件,这种方式在很多中小规模的项目中还好,但在复杂的项目中,下面这些缺点就非 ...
- 基于springmvc静态文件资源配置问题
1.在这里只教大家一种非常实用的 比较简单的一种: 如果两种都配置记得注释掉这种:
- bootstrap基本用法
进入中文官网:http://www.bootcss.com 开始第一个Demo 准备工作: (1)进入bootstrap中文官网,点击起步 (2)下载生产环境 下载好的文件是一 ...
- MS16-032提权正确方法
原版MS16-032提权会Spawn一个System Shell出来,只能通过Remote Desktop获取.这里修改exploit,直接反弹Shell.注意MS16-032依赖 thread ha ...
- Python3 文件基本操作
Python文件的打开模式有: r,只读模式(默认).w,只写模式.[不可读:不存在则创建:存在则删除内容:]a,追加模式.[可读: 不存在则创建:存在则只追加内容:]"+" 表示 ...
- 基于Django Form源码开发自定义Form组件
import copy import re class ValidateError(Exception): def __init__(self, detail): self.detail = deta ...
- C基础 内存越界和内存监测的简单处理
引言 突然感觉要出去走走了, 醒了后 刷完牙就在联系coding, 不知不觉到了 黄昏. 看看天, 打开灯. 又感觉到了 夜夜夜夜 . 13年到北京务工, 遇到一批批NB的同龄人物. 一块工作, 一块 ...
- API(选项/数据 选项/dom)
选项/数据 data 类型: Object | Function 限制: 组件的定义只接受function var data = { a: 1 } // 直接创建一个实例 var vm = new V ...
- Centos7 安装
一.先把Centos7的镜像下载到本地 镜像下载网址:http://archive.kernel.org/centos-vault/ (里面有任何需要的版本) 二.启动VMware 1. 创建新的虚拟 ...
- Nginx web proxy NFS服务
1.nginx web 安装 配置 #systemctl stop firewalld #systemctl disabled firewalld #wget -O /etc/yum.repos.d/ ...