TIANKENG’s restaurant

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1360    Accepted Submission(s): 545

Problem Description
TIANKENG manages a restaurant after graduating from ZCMU, and tens of thousands of customers come to have meal because of its delicious dishes. Today n groups of customers come to enjoy their meal, and there are Xi persons in the ith group in sum. Assuming that each customer can own only one chair. Now we know the arriving time STi and departure time EDi of each group. Could you help TIANKENG calculate the minimum chairs he needs to prepare so that every customer can take a seat when arriving the restaurant?
 
Input
The first line contains a positive integer T(T<=100), standing for T test cases in all.

Each cases has a positive integer n(1<=n<=10000), which means n groups of customer. Then following n lines, each line there is a positive integer Xi(1<=Xi<=100), referring to the sum of the number of the ith group people, and the arriving time STi and departure time Edi(the time format is hh:mm, 0<=hh<24, 0<=mm<60), Given that the arriving time must be earlier than the departure time.

Pay attention that when a group of people arrive at the restaurant as soon as a group of people leaves from the restaurant, then the arriving group can be arranged to take their seats if the seats are enough.

 
Output
For each test case, output the minimum number of chair that TIANKENG needs to prepare.
 
Sample Input
2
2
6 08:00 09:00
5 08:59 09:59
2
6 08:00 09:00
5 09:00 10:00
 
Sample Output
11
6
题并不难,
题意:一组数据中每个开头是一个整数代表此组人的人数,接下来是此组人的到达时间和走的时间,如果两组人的
        时间区间不相交,则第二组人可以使用第一组人用过的桌子,如果相交,就必须重新安排桌子,问最少需要多少桌子
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 10010
using namespace std;
struct node
{
int come;
int go;
int peo;
}s[MAX];
int dp[MAX];
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int t,n,m,j,i;
int ha,hb,ma,mb;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(dp,0,sizeof(dp));
for(i=0;i<n;i++)
{
scanf("%d %d:%d %d:%d",&s[i].peo,&ha,&ma,&hb,&mb);
s[i].come=ha*60+ma;
s[i].go=hb*60+mb;
for(j=s[i].come;j<s[i].go;j++)
{
dp[j]+=s[i].peo;
}
}
sort(dp,dp+MAX,cmp);
printf("%d\n",dp[0]);
}
return 0;
}

  

hdoj 4883 TIANKENG’s restaurant【贪心区间覆盖】的更多相关文章

  1. HDOJ 4883 TIANKENG’s restaurant

    称号: TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Ja ...

  2. hdoj 1050 Moving Tables【贪心区间覆盖】

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. 高效算法——E - 贪心-- 区间覆盖

    E - 贪心-- 区间覆盖 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/E 解题思路: 贪心思想, ...

  4. 【题解】Cut the Sequence(贪心区间覆盖)

    [题解]Cut the Sequence(贪心区间覆盖) POJ - 3017 题意: 给定一大堆线段,问用这些线段覆盖一个连续区间1-x的最小使用线段的数量. 题解 考虑一个这样的贪心: 先按照左端 ...

  5. UVA 10382 - Watering Grass【贪心+区间覆盖问题+高精度】

    UVa 10382 - Watering Grass n sprinklers are installed in a horizontal strip of grass l meters long a ...

  6. 南阳OJ-12-喷水装置(二)贪心+区间覆盖

    题目链接: http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=12 题目大意: 有一块草坪,横向长w,纵向长为h,在它的橫向中心线上不同位置处装有 ...

  7. nyoj 12——喷水装置二——————【贪心-区间覆盖】

    喷水装置(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 有一块草坪,横向长w,纵向长为h,在它的橫向中心线上不同位置处装有n(n<=10000)个点状的 ...

  8. 51nod 1091 线段的重叠【贪心/区间覆盖类】

    1091 线段的重叠 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 X轴上有N条线段,每条线段包括1个起点和终点.线段的重叠是这样来算的,[10 2 ...

  9. 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 ...

随机推荐

  1. 标准的最大margin问题

    standard large margin problem 分割线

  2. Java面向对象程序设计--接口和内部类

    1.接口的定义: In the Java programming language, an interface is not a class but          staff[0] =       ...

  3. 重要业务MySQL冷备解决方案

    1.概述 在公司业务里面,当对应的业务数据不是很重要的时候,我们一般会简单的写个脚本,每天半夜把数据库数据全量拉取下来,备份到本地磁盘.但当业务比较重要的时候,这样简单操作会存在许多问题,比如本地磁盘 ...

  4. PHP 面向对对象基础(接口,类)

    介绍PHP面向对象的基础知识 1. 接口的定义interface ,类定义class,类支持abstract和final修饰符,abstract修饰为抽象类,抽象类 不支持直接实例化,final修饰的 ...

  5. python中os模块的常用接口和异常中Exception的运用

    1.os.path.join(arg1, arg2) 将arg1和arg2对应的字符串连接起来并返回连接后的字符串,如果arg1.arg2为变量,就先将arg1.arg2转换为字符串后再进行连接. 2 ...

  6. 使用pyinstaller 2.1将python打包并添加版本信息和图标

    最近用 wxpython写了一个小的脚本,因为想要发布给没有装python和wxpython的人使用,遂决定使用pyinstaller 2.1进行打包. 其中遇到几个问题: 1,给打包的文件添加图标 ...

  7. python基础 [Alex视频]

    vi hello.py#!/usr/bin/env pythonprint "hello world!"while True: print("hello world!&q ...

  8. init_sequence所对应的函数

    一.init_sequence内容 init_fnc_t *init_sequence[] = { cpu_init, /* basic cpu dependent setup */ board_in ...

  9. JSP中两种模式的总结

    运用JSP/Servlet实现的Web动态交互,主要采用: 模式一:JSP+JavaBean 链接:http://wxmimperio.coding.io/?p=155 模式二;JSP+Servlet ...

  10. 流的概念(来自MSDN)

    本文来源 定义 提供字节序列的一般视图.Provides a generic view of a sequence of bytes. 流涉及三个基本操作 Streams involve three ...