51nod1563
2024-10-12 21:26:14
题解:
其实只要排个序贪心一下就好了。。。代码600B不到。。。
代码:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+,INF=1e9;
int n,x,w;
struct node
{
int l,r;
}a[N];
bool cmp(node a,node b)
{
if (a.r==b.r)return a.l<b.l;
return a.r<b.r;
}
int main()
{
scanf("%d",&n);
for (int i=;i<n;i++)
{
scanf("%d%d",&x,&w);
a[i].l=x-w;
a[i].r=x+w;
}
sort(a,a+n,cmp);
int L=-INF,ans=;
for (int i=;i<n;i++)
if (a[i].l>=L)
{
L=a[i].r;
ans++;
}
printf("%d",ans);
}
最新文章
- User space 与 Kernel space
- [原]excel启动时死锁
- Java多线程14:生产者/消费者模型
- Spark核心概念
- MyBatis(3.2.3) - Configuring MyBatis using XML, typeHandlers
- 汉诺塔 Hanoi Tower
- DEV LookUpEdit 使用方法
- js数组练习
- Python之常用模块(待更新)
- H5学习第二周
- openpose模型在AI challenge人体骨骼关键点检测的表现
- mysql中使用show table status 查看表信息
- Java Pom.xml 详解
- 【Unity】微信支付SDK官方安卓Demo的使用问题
- 域渗透分析神器BloodHound
- U890采购入库单修改供应商
- 四维动规 洛谷P1004方格取数
- MySQL 创建自定义函数
- UVa 674 Coin Change(完全背包)
- Use a layout_width of 0dip instead of fill_parent for better performance
热门文章
- Python3基础 __len__,__getitem__ 记录列表中元素访问的次数 定制不可变序列,下标字典
- 项目管理PV、EV、AC、BAC、EAC、ETC等计算
- POJ3241 Object Clustering(最小生成树)题解
- spring-boot-devtools 实现热部署
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的作用
- pycaffe编译
- HDU 6069 Counting Divisors(唯一分解定理+因子数)
- C指针的一些知识
- URAL 1658 Sum of Digits
- C#中正确使用enum做Key的姿势