Flo's Restaurant

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 932    Accepted Submission(s): 285

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

Author
Alcyone

Recommend
Eddy

让排队的时间尽量短

#include<stdio.h>
#include<string.h>
int s[4][125];
int main()
{
while (scanf("%d%d%d",s[1],s[2],s[3])!=EOF)
{
if (s[1][0]+s[2][0]+s[3][0]==0) return 0;
memset(&s[1][1],0,sizeof(s[1])-4);
memset(&s[2][1],0,sizeof(s[2])-4);
memset(&s[3][1],0,sizeof(s[3])-4);
int ans=0,H,M,N,i;
char ch;
getchar();
ch=getchar();
while (ch!='#')
{
scanf("%d:%d%d",&H,&M,&N);
getchar();
H+=(ch-48)*10;
ch=getchar();
int x=(N-1)/2+1,T=H*60+M,v,Min;
bool flag=false;
for (i=1;i<=s[x][0];i++)
{
if (T>=s[x][i])
{
s[x][i]=T+30;
flag=true;
ans+=N;
break;
}
}
if (!flag)
{
Min=2000;
for (i=1;i<=s[x][0];i++)
if (s[x][i]-T<Min)
{
Min=s[x][i]-T;
v=i;
}
if (Min<=30)
{
ans+=N;
s[x][v]+=30;
}
}
}
printf("%d\n",ans);
}
return 0;
}

Flo's Restaurant[HDU1103]的更多相关文章

  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

    [poj2424]Flo's Restaurant Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2960   Accept ...

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

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

  4. [转] POJ DP问题

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

  5. poj动态规划列表

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

  6. POJ动态规划题目列表

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

  7. POJ 动态规划题目列表

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

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

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

  9. 别人整理的dp题目

    动态规划 动态规划 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 14 ...

随机推荐

  1. 5款Linux最佳照片管理软件

    在谈到 Linux 中的应用程序时,对于不同的用户.不同的使用场景以及不同的使用习惯,在同一类应用当中,总会有多种软件可供选择和备选.就 Linux 中的照片管理软件来说,相信此前的 Google P ...

  2. ubuntu打不开图形界面,显示run in low_graphic mode

    我上次因为这个问题重装了ubuntu,结果没两天又有问题了,这次我看到了未重启前的提示,说我的硬盘空间剩0kb,所以我心有余悸的想办法留空间,十分担心会有上次的问题出现,为了验证我的想法,我重启了一下 ...

  3. 他们在军训,我在搞 OI(二)

    Day 2 7:26 2016/8/25 新的一天又开始了! 走在上学的路上,抬头看看北京少有的蓝天,太阳的威力不再那么明显,甚至输给了挡住它的云朵.迎面吹来了凉爽的风,夏天的燥热,早已无影无踪. 许 ...

  4. 在Shell里面判断字符串是否为空

     在Shell里面判断字符串是否为空 分类: Linux shell2011-12-28 23:18 15371人阅读 评论(0) 收藏 举报 shell 主要有以下几种方法: echo “$str” ...

  5. linux使用技巧

    <1>vim /etc/hosts.deny sshd : 192.168.0.25 :deny              //ssh拒绝某ip或网段访问.(原理详见鸟哥基础版18章P56 ...

  6. error splicing file: file too large解决方法

    FAT32格式的usb最大支持4G的文件,拷贝超过4G的文件需要把usb换成NTFS格式.

  7. css选择器集体声明

    <title>静夜思</title><style type="text/css">h1,#two,.red{ color:#ff0000; fo ...

  8. scrapy爬虫成长日记之将抓取内容写入mysql数据库

    前面小试了一下scrapy抓取博客园的博客(您可在此查看scrapy爬虫成长日记之创建工程-抽取数据-保存为json格式的数据),但是前面抓取的数据时保存为json格式的文本文件中的.这很显然不满足我 ...

  9. Extjs给gridPanel添加单价双击事件和获取当前行的数据

    有两个小属性,如下 this.on('rowdblclick', this.readContent, this); this.on('cellclick', this.gridCellClick, t ...

  10. 配置SecureCRT连接本地虚拟机中的Linux系统

    转自:http://www.pythoner.com/196.html 由于平时公司开发时都是使用SecureCRT连接的Linux服务器,所以也想使用SecureCRT在自己电脑上连接本地虚拟机中的 ...