51nod 1133 不重叠的线段
2017-07-27 20:17
204 查看
传送门---不重叠的线段
贪心--好像和一个看电视节目的是一个题
贪心--好像和一个看电视节目的是一个题
#include <iostream> #include <algorithm> #include <stdio.h> using namespace std; struct node { int x,y; }; bool cmp (node a,node b) { return a.y<b.y; } int main() { struct node t[10001]; int n; while(cin>>n) { for(int i=0;i<n;i++) scanf("%d %d",&t[i].x,&t[i].y); sort(t,t+n,cmp); int ans=1; int tmp=t[0].y; for(int i=1;i<n;i++) { if(t[i].x>=tmp) { ans++; tmp=t[i].y; } } cout<<ans<<endl; } return 0; }
相关文章推荐
- 51nod 1133 不重叠的线段 贪心
- 51nod 1133 不重叠的线段
- 51Nod 1133 不重叠的线段 贪心
- 51Nod-1133-不重叠的线段
- 51nod 1133 不重叠的线段(贪心)
- 51nod 1133 不重叠的线段 贪心
- 51nod 1133 不重叠的线段(贪心)
- 51Nod 1133 不重叠的线段 (区间贪心
- 51nod-1133 不重叠的线段
- 51Nod 1133 不重叠的线段 | 典型贪心
- 【51nod】---1133 不重叠的线段(贪心)
- 51Nod 1133 不重叠的线段
- 51nod 1133 不重叠的线段 贪心
- 51nod 1133 不重叠的线段(贪心)
- 51nod 1133 不重叠的线段(贪心)
- 51NOD 1133 不重叠的线段
- 51nod 1133 不重叠的线段
- 51nod 1133 不重叠的线段(贪心)
- 51nod 1133 不重叠的线段(贪心)
- 51nod 1133 不重叠的线段