51Nod-1563-坐标轴上的最大团
来源:互联网 发布:淘宝客服的服务用语 编辑:程序博客网 时间:2024/05/20 21:57
ACM模版
描述
题解
这个题根据题意,我们知道,根据
代码
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;const int MAXN = 2e5 + 10;const int INF = 0x3f3f3f3f;struct node{ int l, r;};int n;node a[MAXN];bool cmp(node a, node b){ if (a.r == b.r) { return a.l < b.l; } return a.r < b.r;}int main(){ cin >> n; int x, w; for (int i = 0; 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; int ans = 0; for (int i = 0; i < n; i++) { if (a[i].l >= L) { L = a[i].r; ans++; } } cout << ans << endl; return 0;}
阅读全文
0 0
- 51Nod-1563-坐标轴上的最大团
- 51nod 1563 坐标轴上的最大团 (贪心)
- [51nod-1563]坐标轴上的最大团
- 51 Nod 1563——坐标轴上的最大团
- 【51Nod1563】坐标轴上的最大团
- 51nod 1524 可除图的最大团【dp】
- 51nod-1524 可除图的最大团
- 51Nod-1524-可除图的最大团
- 51nod 1524 可除图的最大团
- 51nod 1524 可除图的最大团 dp
- 51nod-1524 可除图的最大团(DP)
- 51nod 1524 可除图的最大团(DP)
- 最大团的求法
- 对最大团的理解
- 最大团
- 最大团
- 最大团
- 最大团
- 一个小菜鸡封装继承的制作披萨
- USART总结
- Drying<二分,思维题>
- java日记——final、abstract与抽象类
- HDU 6034
- 51Nod-1563-坐标轴上的最大团
- hud 3853 LOOPS (dp求概率期望)
- 跨平台日志清理工具 Log-Cutter v1.0.3 正式发布
- Android开发蓝牙篇之蓝牙设备开启、搜索周边蓝牙设备
- 散列表及冲突的解决办法
- Linux常见设备
- 【API】Unity5.6 Animation transitions
- G
- POJ 1222 EXTENDED LIGHTS OUT(高斯消元)