BZOJ2501: [usaco2010 Oct]Soda Machine
2024-09-07 08:50:38
n<=50000个区间,求哪个点被覆盖区间数量最多,输出这个数量。
差分模板。。然而数组忘开两倍。。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
//#include<iostream>
using namespace std; int n;
#define maxn 100011
struct eve
{
int p,v;
bool operator < (const eve &b) const
{return p<b.p || (p==b.p && v<b.v);}
}e[maxn];int le=;
int x,y;
int main()
{
scanf("%d",&n);
for (int i=;i<=n;i++)
{
scanf("%d%d",&x,&y);
e[++le].p=x;e[le].v=;
e[++le].p=y+;e[le].v=-;
}
sort(e+,e++le);
int now=,ans=;
for (int i=;i<=le;i++)
{
now+=e[i].v;
ans=max(ans,now);
}
printf("%d\n",ans);
return ;
}
最新文章
- css伪类制作三角箭头
- ubuntu配置NFS
- 使用D3绘制图表(2)--绘制曲线
- [cb] Unity Editor 添加右键菜单
- HealthKit开发教程之HealthKit的复合数据
- FileUpload无法赋值解决方案
- No resource found that matches the given name
- 调试NodeJS应用
- 关于left join连接查询 两张表里有同名字段的问题
- MFC--自定义消息
- 添加<;!doctype html>;后造成JS写的定位失效
- SignalR的Javascript客户端API使用方式整合
- 20190326-HTML5标签、CSS的引用
- Python高级应用(3)—— 为你的项目添加验证码
- Spark核心RDD、什么是RDD、RDD的属性、创建RDD、RDD的依赖以及缓存、
- Struts自定义拦截器&;拦截器工作原理
- css的浮动
- MODBUS RTU协议中浮点数是如何存储,读到浮点数寄存器的数值如何转换成所需的浮点数
- 线段树之Sum
- sublime text 3103 怎么设置中文