bzoj1651
来源:互联网 发布:阿里巴巴农村淘宝图片 编辑:程序博客网 时间:2024/05/18 01:14
分析:按照差分的思想,区间的左端点+1,右端点-1,扫一遍就好了。。反正才1e6.
然后WA了一发,不知道哪里错,后来才发现,要a[r+1]–,因为他给出的时间是l到r,那么r也是有的。。
#include<cstdio>#include<cstring>#include<algorithm>#include<math.h>#define fo(i,a,b) for(int i=a;i<=b;i++)#define fd(i,a,b) for(int i=a;i>=b;i--)using namespace std;typedef long long ll;const int inf=1e9+5;int n,m;const int N=1e5+5;const int M=2e6+5;int tim[M];int main(){ scanf("%d",&n); int left=1,right=1000000; fo(i,1,n) { int l,r; scanf("%d%d",&l,&r); tim[l]++,tim[r+1]--; //right=max(right,r); //left=min(left,l); } int ans=0,tot=0; fo(i,left,right) { tot+=tim[i]; //printf("%d\n",tot); ans=max(ans,tot); } printf("%d\n",ans); return 0;}
0 0
- bzoj1651
- bzoj1651
- bzoj1651(差分)
- bzoj1651[Usaco2006 Feb]Stall Reservations 专用牛棚
- [BZOJ1651] [Usaco2006 Feb]Stall Reservations 专用牛棚
- bzoj1651: [Usaco2006 Feb]Stall Reservations 专用牛棚
- bzoj1651: [Usaco2006 Feb]Stall Reservations 专用牛棚
- BZOJ1651--[Usaco2006 Feb]Stall Reservations 专用牛棚
- [bzoj1651][Usaco2006 Feb]Stall Reservations 专用牛棚
- [BZOJ1651][Usaco2006 Feb]Stall Reservations 专用牛棚(线段树)
- class文件JDK版本查看
- resultMap 多对多查询
- 自定义圆内套三角形
- ORACLE 学习笔记 -->存储过程,游标等
- 理解Maven中的SNAPSHOT版本和正式版本
- bzoj1651
- 代码备忘录(1)影像地理坐标的获取以及坐标系之间的转换(基于GDAL)
- Android内存泄漏
- 【Zookeeper】源码分析之Leader选举(二)
- 商派BBC系统——<{input type=?类型组件
- [Jenkins]TestNG无法显示,提示“testng-results.xml was last modified before this build started”
- Android锁屏以及锁键盘(锁触摸)
- git学习教程
- 点击按钮Alert弹出遮罩层效果的提示框代码