bzoj1651(差分)
来源:互联网 发布:富士康跳樓事件知乎 编辑:程序博客网 时间:2024/05/16 15:38
其实就是找一个点,使覆盖的线段最多。
经典差分,注意需要离散化
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<algorithm>using namespace std;int n;struct aa{int l,r;}q[50005];int h[100005];int add[100005],ji[100005];int main(){scanf("%d",&n);int tot=0;for (int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),h[++tot]=q[i].l,h[++tot]=q[i].r;sort(h+1,h+tot+1);tot=unique(h+1,h+tot+1)-h-1;for (int i=1;i<=n;i++){int l=lower_bound(h+1,h+tot+1,q[i].l)-h;int r=lower_bound(h+1,h+tot+1,q[i].r)-h;add[l]++;ji[r]++;}int now=0,ans=0;for (int i=1;i<=tot;i++){now+=add[i];if (now>ans) ans=now;now-=ji[i];}printf("%d",ans);return 0;}
总结
1:差分是一个非常重要的思想
0 0
- bzoj1651(差分)
- bzoj1651
- bzoj1651
- ZOJ1508 (差分约束)
- hdu3592(差分约束)
- BZOJ2330(差分约束)
- poj3169Layout (差分约束)
- poj3169Layout(差分约束)
- poj1275(差分约束)
- Intervals (差分约束)
- 种树(差分约束)
- Layout (线性差分)
- hdu3666(差分约束)
- bzoj 3043(差分)
- 差分
- 差分
- 差分
- 差分定位和精密定位(二)--单差,双差,三差
- iOS – Quartz2D & CALayer & CAShapeLayer
- jsp内置对象之session
- 协同过滤itembase计算Spark实现(三)
- your cpu does not support NX
- Android Studio 2.2 正式起航
- bzoj1651(差分)
- (git)Bitbucket使用WebHook实现自动部署PHP代码
- mybaties日常开发总结
- pinyin4j介绍
- jpinyin介绍
- Linux常用命令详解(五)_性能检测
- 独立集
- Codeforces Round #372 (Div. 2) D. Complete The Graph 图论、最短路、Dijkstra、路径、分配部分边权
- 支付宝支付的详细过程