挤牛奶
来源:互联网 发布:淘宝买iphone靠谱商家 编辑:程序博客网 时间:2024/06/09 22:47
题目描述
输入
输出
样例输入
3300 1000700 12001500 2100
样例输出
900 300
提示
#include <stdio.h>
#include<stdlib.h>
typedef struct node
{
int x,y;
} node;
int n,myspace=0,result=0;
node f[10005];
int cmp(const void *a,const void *b)
{
return((*(node*)a).x-(*(node*)b).x);
}
void jisuan()
{
int i,head,maxx=f[0].y;
head=f[0].x;
for(i=1; i<n; i++)
{
if(f[i].x<=maxx&&f[i].y>maxx)maxx=f[i].y;
if(f[i].x>maxx)
{
if((maxx-head)>result)result=maxx-head;
if((f[i].x-maxx)>myspace)myspace=f[i].x-maxx;
head=f[i].x;
maxx=f[i].y;
}
}
if((maxx-head)>result)result=maxx-head;
printf("%d %d",result,myspace);
}
int main()
{
int i;
scanf("%d",&n);
for(i=0; i<n; i++)scanf("%d%d",&f[i].x,&f[i].y);
qsort(f,n,sizeof(f[0]),cmp);
jisuan();
return 0;
}
- 挤牛奶
- 挤牛奶
- 挤牛奶
- 挤牛奶
- 挤牛奶的姑娘
- Milking Cows 挤牛奶
- USACO 挤牛奶
- Milking Cows 挤牛奶
- Milking Cows 挤牛奶
- [P1204]挤牛奶
- 挤牛的牛奶
- P1204 挤牛奶
- USACO题解milk2 挤牛奶
- USACO 2.2.5 挤牛奶
- USACO——挤牛奶
- Milking Cows 挤牛奶--贪心
- usaco 1.2.1 Milking Cows 挤牛奶
- USACO1.2.1 Milking Cows(挤牛奶)
- 蓝桥杯A组试题 大臣旅费
- pdf下载插件tcpdf
- 用html来操作css样式 正则表达式
- ES学习(五)同义词分词器dynamic synonym for ElasticSearch
- nyoj2 括号配对问题
- 挤牛奶
- ServletContext——被称为context域对象
- scala(2)-使用Scala解释器(interpreter)
- ProcessShellCommand(cmdInfo)函数功能
- ProcessShellCommand(cmdInfo)函数功能
- Mitaka版OpenStack中调用ceilometerclient创建alarm的问题
- PAT乙级1012 数字分类
- C++简单加解密
- 正则表达式基础学习