BestCoder Round #2 1001 (简单处理)
题意:给N条信息,每个信息代表有x个人从开始的时间 到 结束的时间在餐厅就餐,
问最少需要多少座位才能满足需要。
分析:由于时间只有24*60 所以把每个时间点放到 数组a中,并标记开始的时间+x,
结束的时间 -x。最后累加比较。
如果时间点太多的时候可以把时间点放到结构体里,排序,然后依次枚举结构体。
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#define LL long long
#define rep(i, a, b)for(int i = a; i < b; i++)
const int maxn = +; using namespace std;
int a[maxn]; int main()
{
int t, n, x, h, m, ans;
cin>>t;
while(t--)
{
memset(a, , sizeof(a));
cin>>n;
while(n--)
{
scanf("%d %d:%d", &x, &h, &m);
a[h*+m] += x;
scanf("%d:%d", &h, &m);
a[h*+m] -= x;
}
ans = ;
rep(i, , maxn-)
a[i] += a[i-];
rep(i, , maxn-)
if(a[i]>ans)
ans = a[i];
cout<<ans<<endl;
}
}
BestCoder Round #2 1001 (简单处理)的更多相关文章
- 贪心 BestCoder Round #39 1001 Delete
题目传送门 /* 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少: 否则再在tot里减去多余的即为答案 用set容器也可以做,思路一样 */ # ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- 暴力 BestCoder Round #46 1001 YJC tricks time
题目传送门 /* 暴力:模拟枚举每一个时间的度数 详细解释:http://blog.csdn.net/enjoying_science/article/details/46759085 期末考结束第一 ...
- 字符串处理 BestCoder Round #43 1001 pog loves szh I
题目传送门 /* 字符串处理:是一道水题,但是WA了3次,要注意是没有加'\0'的字符串不要用%s输出,否则在多组测试时输出多余的字符 */ #include <cstdio> #incl ...
- BestCoder Round #75 1001 - King's Cake
Problem Description It is the king's birthday before the military parade . The ministers prepared a ...
- BestCoder Round #92 1001 Skip the Class —— 字典树 or map容器
题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1001 题解: 1.trie树 关 ...
- BestCoder Round #87 1001
GCD is Funny Accepts: 524 Submissions: 1147 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 655 ...
- HDU 5776 sum (BestCoder Round #85 A) 简单前缀判断+水题
分析:就是判断简单的前缀有没有相同,注意下自身是m的倍数,以及vis[0]=true; #include <cstdio> #include <cstdlib> #includ ...
- BestCoder Round #61 1001 Numbers
Problem Description There are n numbers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A1,A2....An,yo ...
随机推荐
- .net speed up
Ngen.exe http://www.cnblogs.com/yukaizhao/archive/2011/11/07/how-to-use-ugen.html Merge.exe Merge dl ...
- Interview-Increasing Sequence with Length 3.
Given an array, determine whether there are three elements A[i],A[j],A[k], such that A[i]<A[j]< ...
- swift 类 与 结构体
这两天突然有人问我 swift里面 类和 结构体 有什么区别? 说实在的本人目前不太看好swift,相信很多人也是,oc 都 很成熟了. 本人目前不打算深入了解swift的原因swift 语言 ...
- Maven搭建webService (二) 创建服务端---使用web方式发布服务
今天和大家分享 使用 web方式发布 webService 服务端.客户端 1.首先创建 一个web工程(增加Maven依赖) 2.增加Maven依赖包,如下: <!-- spring core ...
- javascript数学计算
◎Math.ceil()执行向上舍入,即它总是将数值向上舍入为最接近的整数:◎Math.floor()执行向下舍入,即它总是将数值向下舍入为最接近的整数:◎Math.round()执行标准舍入,即它总 ...
- WPF Loader
xaml <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml ...
- Capsule:开源的 JVM 应用部署工具
[编者按]本文作者 Ron Pressler 是 Parallel Universe 公司的创始人,拥有着丰富的高性能开发经验.通过这篇文章,Ron 向大家详细介绍了全新的开源 JVM 部署工具--C ...
- Javascript的动态运动(1)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- 系统学习sqlserver2012 一
一:使用管理服务器和脚本 在试图菜单中选族已注册的服务器,可以直接切换登录服务器 在试图菜单中选择解决方案资源管理器,可以直接打开之前保存的脚本,方便管理和执行 这两种保存时,都可以分组保存,见下图
- Java学习笔记(一) java介绍
编程语言分为:编译型语言和解释型语言. 编译型语言需要经过特定编译器通过一次性编译,成为该特定平台硬件可执行的机器码,可脱离开发环境独立运行,运行效率较高,但是无法跨平台移植. 解释型语言需要经过特定 ...