HDU 1103 Flo's Restaurant(模拟+优先队列)
Flo's Restaurant
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1519 Accepted Submission(s): 465
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.
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.
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
7
3 12 直接模拟,一开始我用一个优先队列表示所有的餐桌,后来发现行不通的,只能用三个优先队列表示三个餐桌,然后就是简单模拟#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue> using namespace std;
int A,B,C;
int a[10];
struct Node
{
int time;//吃完饭的时间
int pos;//几号桌
int p;//几个人
friend bool operator<(Node n1,Node n2)
{
return n1.time>n2.time;
}
Node(){};
Node(int time,int pos,int p){this->time=time;this->pos=pos;this->p=p;}
}d;
priority_queue<Node>q[10];
char e[105];
int num;
int main()
{
while(scanf("%d%d%d",&a[2],&a[4],&a[6])!=EOF)
{
if(a[2]==0&&a[4]==0&&a[6]==0)
break;
int cot=0;
for(int i=2;i<=6;i+=2)
{
while(!q[i].empty())
q[i].pop();
for(int j=1;j<=a[i];j++)
q[i].push(Node(0,i,0));
}
int ans=0;
while(scanf("%s",e))
{
if(e[0]=='#')
break;
scanf("%d",&num);
d.time=((e[0]-'0')*10+e[1]-'0')*60+(e[3]-'0')*10+e[4]-'0';
d.p=num;
d.pos=(num&1?num+1:num);
Node term=q[d.pos].top();
if(d.time>=term.time) {d.time+=30;ans+=d.p;q[d.pos].pop();q[d.pos].push(d);}
else if(d.time+30>=term.time) {d.time=term.time+30;ans+=d.p;q[d.pos].pop();q[d.pos].push(d);}
}
printf("%d\n",ans);
}
return 0;
}
HDU 1103 Flo's Restaurant(模拟+优先队列)的更多相关文章
- hdu 5437 Alisha’s Party 模拟 优先队列
Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her f ...
- 【模拟】Flo's Restaurant
[poj2424]Flo's Restaurant Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2960 Accept ...
- Flo's Restaurant[HDU1103]
Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- hdu6136[模拟+优先队列] 2017多校8
有点麻烦.. /*hdu6136[模拟+优先队列] 2017多校8*/ #include <bits/stdc++.h> using namespace std; typedef long ...
- HDU 5437 Alisha’s Party (优先队列模拟)
题意:邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每次都是礼物价值高的人先进.最后 ...
- HDU 4883 TIANKENG’s restaurant Bestcoder 2-1(模拟)
TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/O ...
- hdu 2364 Escape【模拟优先队列】【bfs】
题目链接:https://vjudge.net/contest/184966#problem/A 题目大意: 走迷宫.从某个方向进入某点,优先走左或是右.如果左右都走不通,再考虑向前.绝对不能往后走, ...
- HDU 1789 - Doing Homework again - [贪心+优先队列]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 Time Limit: 1000/1000 MS (Java/Others) Memory Li ...
随机推荐
- php微信开发 -- 两种运营模式及服务器配置
微信的两种运营模式 编辑模式:使用微信公众平台提供的功能 开发者模式:通过腾讯的api接口调用相应程序进行二次开发 编辑模式 应用场景: l 不具备开发能力的运营者 l 主要是进行品牌宣传.新闻媒体. ...
- 【Java 线程的深入研究1】Java 提供了三种创建线程的方法
Java 提供了三种创建线程的方法: 通过实现 Runnable 接口: 通过继承 Thread 类本身: 通过 Callable 和 Future 创建线程. 1.通过实现 Runnable 接口来 ...
- Sprite与屏幕之间的关系
锚点这东西挺怀念的,N年前我在做J2ME手游的时候.屏幕整体的坐标是左上角是00点.X轴向右递增,Y轴向下递增.所有的image也是这个原理.只是unity的触摸屏坐标不是左上角,而是左下角. 所以这 ...
- 第四章 Spring.Net 如何管理您的类___自定义对象行为
Spring.Net 一直讲求 ” 配置应用程序“,有一种需求在实际开发中不太常用,却非常有用 -> 配置对象的行为,Spring.Net 也能够完美的实现.Spring.Net 通过几个专门的 ...
- Razor------引入css文件的方法
MVC3.0之前版本: <link href=@Url.Content("~/Content/Styles.css") rel="stylesheet" ...
- GIS-011-Cesium 使用 IIS设置
.terrain Content-Type='application/octet-stream'
- Spring new对象时注解失效
新建了一个新类(A)后,在类中用注解将属性注入.类名(A)上用 @Component ,类中的一个属性(name)上用 @Autowired或@Resource, 方法(fun)中通过 属性(name ...
- 关于C#我今天的六个小时
嘿嘿,今天周六啦,我们是自由学习啦,于是还记得前几天纠结的事情,还有好多不太熟悉的题目那,于是今天就找出来练习下拉,而且这些题目在老师给我们复习时间也给我们讲解过啦,这样一来应该做起来还是容易点的啦, ...
- PHP Web 木马扫描器代码
scanner.php:<?php/**************PHP Web木马扫描器************************//* [+] 作者: alibaba *//* [+] ...
- Spring学习笔记--构造器注入
之前讲到的名为"duke"的bean有一个私有成员变量beanBags代表这个杂技师bean的一次性能够抛出的最多的数量,Juggler有一个构造函数,构造函数的第一个参数(这里只 ...