Codeforce 527D Clique Problem题解
2016-01-19 17:18
417 查看
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; #define MAXN 200001 struct LINE{int l,r;}a[MAXN]; int N,ans=0; bool cmp(LINE A,LINE B){return A.r<B.r;} int main() { scanf("%d",&N); for(int i=1;i<=N;i++) { int X,W; scanf("%d%d",&X,&W); a[i].l=X-W; a[i].r=X+W; } sort(a+1,a+1+N,cmp); int now=a[1].r;ans=1; for(int i=2;i<=N;i++) if(a[i].l>=now) { ans++; now=a[i].r; } printf("%d\n",ans); return 0; }
相关文章推荐
- String 字符串常量,StringBuffer 字符串变量(线程安全),StringBuilder (非线程安全)
- ValueError: Still no compile flags, no completions yet.
- 2016.01.18 UILabel
- GXUI 的认识
- 常用的安卓UI相关的工具集合
- iOS UITableView 左滑删除cell
- 160119UINavigationController使用详解
- FTP(FtpWebRequest/FtpWebResponse) 上传下载
- js模块话开发3::require.js的用法
- 给UILabel设置圆角
- 【HDU】2610 Sequence one
- IOS本地通知:UILocalNotification使用记录
- 借鉴drawable文件夹,values使用dimens控制字体大小、边距大小。适配Android不同机型,不同屏幕
- 1月19号 UIImageView
- MySQL学习10_使用chown更改/var/lib所有者导致Starting MySQL. ERROR! The server quit without updating PID file错误
- iOS UIScrollview 和侧滑手势冲突解决方法
- iOS--UINavigationBar使用总结
- request各个方法,获取各种路径
- Request.QueryString[""] 与 Request[""] 、 Request.QueryString[""].Tostring()
- iOS小技巧–用runtime 解决UIButton 重复点击问题