题解:

其实只要排个序贪心一下就好了。。。代码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);
}

最新文章

  1. User space 与 Kernel space
  2. [原]excel启动时死锁
  3. Java多线程14:生产者/消费者模型
  4. Spark核心概念
  5. MyBatis(3.2.3) - Configuring MyBatis using XML, typeHandlers
  6. 汉诺塔 Hanoi Tower
  7. DEV LookUpEdit 使用方法
  8. js数组练习
  9. Python之常用模块(待更新)
  10. H5学习第二周
  11. openpose模型在AI challenge人体骨骼关键点检测的表现
  12. mysql中使用show table status 查看表信息
  13. Java Pom.xml 详解
  14. 【Unity】微信支付SDK官方安卓Demo的使用问题
  15. 域渗透分析神器BloodHound
  16. U890采购入库单修改供应商
  17. 四维动规 洛谷P1004方格取数
  18. MySQL 创建自定义函数
  19. UVa 674 Coin Change(完全背包)
  20. Use a layout_width of 0dip instead of fill_parent for better performance

热门文章

  1. Python3基础 __len__,__getitem__ 记录列表中元素访问的次数 定制不可变序列,下标字典
  2. 项目管理PV、EV、AC、BAC、EAC、ETC等计算
  3. POJ3241 Object Clustering(最小生成树)题解
  4. spring-boot-devtools 实现热部署
  5. /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的作用
  6. pycaffe编译
  7. HDU 6069 Counting Divisors(唯一分解定理+因子数)
  8. C指针的一些知识
  9. URAL 1658 Sum of Digits
  10. C#中正确使用enum做Key的姿势