TIANKENG’s restaurant
来源:互联网 发布:淘宝强行退款 编辑:程序博客网 时间:2024/06/05 16:09
题目链接
- 题意:
n组人,每组一行输入:人数,到达时间,离开时间。问人数最多是多少(如果同一时刻有人到有人离开,那么先让人离开) - 分析:
把一组人拆成两个点,左端点和右端点,从左向右扫描。如果遇到一个左端点,加入集合中;如果遇到一个右端点,就把集合中对应的点删去即可。
const int MAXN = 110000;struct Node{ int num, isr, id, time; bool operator< (const Node& rhs) const { if (time != rhs.time) return time < rhs.time; return isr > rhs.isr; }} ipt[MAXN];int main(){ int T, a, b, c, d, n, num; RI(T); FE(kase, 1, T) { RI(n); REP(i, n) { scanf("%d %d:%d %d:%d", &num, &a, &b, &c, &d); int x = i << 1, y = x | 1; ipt[x].isr = 0; ipt[x].time = a * 60 + b; ipt[y].isr = 1; ipt[y].time = c * 60 + d; ipt[x].id = ipt[y].id = i; ipt[x].num = ipt[y].num = num; } n <<= 1; sort(ipt, ipt + n); set<int> st; int ans = 0, tans = 0; REP(i, n) { if (ipt[i].isr) { st.erase(ipt[i].id); tans -= ipt[i].num; } else { st.insert(ipt[i].id); tans += ipt[i].num; } ans = max(ans, tans); } WI(ans); } return 0;}
1 0
- TIANKENG’s restaurant
- TIANKENG’s restaurant
- HDU_4883 TIANKENG’s restaurant
- hdu TIANKENG’s restaurant
- hdoj4883 TIANKENG’s restaurant
- TIANKENG’s restaurant
- HDOJ TIANKENG’s restaurant
- TIANKENG’s restaurant
- 4883 TIANKENG’s restaurant
- hd4883 TIANKENG’s restaurant
- TIANKENG’s restaurant--hdu4883
- TIANKENG’s restaurant
- B - TIANKENG’s restaurant
- TIANKENG’s restaurant
- TIANKENG’s restaurant
- TIANKENG’s restaurant
- TIANKENG’s restaurant HDU
- HDOJ 4883 TIANKENG’s restaurant
- VxWorks 系统时间时区设置
- ISA95的抽象惯例
- ffplay parameters
- poj 1258 Agri-Net(最小生成树,普里姆算法)
- ios--MBProgressHUD(使用方式一)--在事件的执行过程中显示+指定显示时间长短
- TIANKENG’s restaurant
- Gray Code
- ArcGis for android 加载tpk离线文件(http://blog.csdn.net/vpingchangxin/article/details/8778869)
- hdu 4893 线段树+二分fib
- Spring AOP(面向切面编程)【Spring AOP的技术基础】
- 分享:APK高级保护方法解析(一)
- 关于二进制补码
- 把字符串转换为整数
- Business Rules(From Wiki)