P1204 挤牛奶
来源:互联网 发布:付费炒股软件排名 编辑:程序博客网 时间:2024/04/27 14:25
https://www.luogu.org/record/lists?pid=P1204
维护区间
#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<queue>#include<vector>#include<cstdio> using namespace std;int n,max1=0,max2=0,maxto=0;struct H{ int head,tail; int mto;}kk[5009];int my_comp(const H&a,const H&b){ if(a.head<b.head) return 1; return 0;}int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&kk[i].head,&kk[i].tail); } sort(kk+1,kk+n+1,my_comp); kk[0].head=kk[0].tail=kk[1].head; int n1=kk[1].head,n2=kk[1].tail;/n1为头,n2为尾 max1=n2-n1; for(int i=1;i<=n;i++) { if(kk[i].head>n2)//区间间断 { max2=max(max2,kk[i].head-n2); max1=max(max1,n2-n1); n1=kk[i].head,n2=kk[i].tail;//跳到下一个区间 } if(kk[i].tail>n2) n2=kk[i].tail;//更新尾 } printf("%d %d",max1,max2);}
1 0
- [P1204]挤牛奶
- P1204 挤牛奶
- 洛谷 P1204 [USACO1.2]挤牛奶Milking Cows
- 洛谷 P1204 [USACO1.2] 挤牛奶Milking Cows
- 【洛谷P1204】【USACO1.2】挤牛奶Milking Cows
- 【模拟】洛谷 P1204 [USACO1.2]挤牛奶Milking Cows
- 挤牛奶
- 挤牛奶
- 挤牛奶
- 挤牛奶
- 挤牛奶的姑娘
- Milking Cows 挤牛奶
- USACO 挤牛奶
- Milking Cows 挤牛奶
- Milking Cows 挤牛奶
- 挤牛的牛奶
- USACO题解milk2 挤牛奶
- USACO 2.2.5 挤牛奶
- Win7下完全卸载Oracle 11g的步骤
- Freeswitch内核研究之录音
- mysql获取数据库名 表名及列名
- POJ 1852 Ants
- 【BZOJ】1008: [HNOI2008]越狱
- P1204 挤牛奶
- Hibernate中使用了序列给主键自动增长,但是添加记录到数据库时报违反唯一性约束??
- mpg123 /root/We\ belong\ to\ the\ sea.mp3
- 解决docker镜像无法下载的问题
- ExpressBox 7 – RAS
- Android集成FFmpeg库录音
- 关于函数,递归
- 开发必备的15个Javascript库
- JAVA中基于UDP实现多线程通信