51nod oj 1091 线段的重叠 【贪心】
来源:互联网 发布:小升初辅导软件 编辑:程序博客网 时间:2024/05/23 16:56
题目链接:1091
排序-.-(减少计算时重复与不必要的次数)
代码“:
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct node{int start,end;}duan[60000];bool cmp(node xx,node yy){if (xx.start!=yy.start)return xx.start<yy.start;return xx.end>yy.end;}int main(){int n;scanf("%d",&n);for (int i=0;i<n;i++)scanf("%d%d",&duan[i].start,&duan[i].end);sort(duan,duan+n,cmp);int s=0,a,b;for (int i=0;i<n;i++){a=duan[i].start;b=duan[i].end;for (int j=i+1;j<n;j++){if (b-duan[j].start<=s)break;s=max(s,min(b-duan[j].start,duan[j].end-duan[j].start));}}printf("%d\n",s);return 0;}
0 0
- 51nod oj 1091 线段的重叠 【贪心】
- 51nod 1091 线段的重叠(贪心)
- 51nod 1091 线段的重叠 贪心
- 51nod 1091 线段的重叠 贪心
- 贪心-51nod 1091 线段的重叠
- 51nod 1091 线段的重叠 (贪心)
- 51nod 1091 线段的重叠(贪心)
- 51Nod 1091 线段的重叠 贪心
- 51nod 线段的重叠(贪心)
- 51nod 1091 线段的重叠 (贪心)
- 51Nod 1091 线段的重叠 (贪心)
- 51nod 1091 线段的重叠(贪心思维)
- 51Nod 1091 线段的重叠 (区间贪心
- 51nod 1091 线段的重叠(贪心)
- 51nod 1091 线段的重叠(贪心)
- 51nod 1091 线段的重叠(贪心)
- 【51nod】-1091 线段的重叠(贪心)
- 51NOD 1091 线段重叠 51 NOD 1133不重叠线段 贪心
- centos下nginx仅允许指定域名访问,不可用ip访问
- HDU 4432 求因子+进制转换
- php自动匹配
- 手把手教你写Js日期时间选择器(3)-让控件滑动起来
- 使用nexus搭建Maven私服
- 51nod oj 1091 线段的重叠 【贪心】
- 可以动态修改时间的CountDownTimer
- ProgressDialog 进展对话框
- 一种基于monitor的系统软件架构
- 1240 莫比乌斯函数(数论)
- 如何解决缺失值
- 网页调试的那些事
- 戏说SpringMVC原理-1
- php 最大堆的实现