Milking Cows /// 区间计数 离散化排序 oj10105
3
300
1000
700 1200
1500 2100
900
300
注意开始结束时间都可能相同 且不一定是按时间顺序的
题解:http://www.xuebuyuan.com/1960543.html
#include <bits/stdc++.h>
using namespace std; struct COW{ int tm,k; }cow[];
bool cmp(COW a,COW b)
{
if(a.tm==b.tm) return a.k>b.k;
return a.tm<b.tm;
} int main()
{
int n;
while(~scanf("%d",&n))
{ int j=;
while(n--)
{
scanf("%d",&cow[j].tm); cow[j++].k=;
scanf("%d",&cow[j].tm); cow[j++].k=;
}
sort(cow+,cow+j,cmp); int key,last,lcon,lid;
key=last=lcon=lid=; for(int i=;i<j;i++)
{
if(cow[i].k) key++;
else key--; if(!key)
{
lcon=max(lcon,cow[i].tm-cow[last+].tm);
lid=max(lid,cow[i+].tm-cow[i].tm);
last=i;
}
}
printf("%d %d\n",lcon,lid);
}
return ;
}
Milking Cows /// 区间计数 离散化排序 oj10105的更多相关文章
- Milking Cows 挤牛奶 USACO 排序 模拟
1005: 1.2.1 Milking Cows 挤牛奶 时间限制: 1 Sec 内存限制: 128 MB提交: 15 解决: 9[提交] [状态] [讨论版] [命题人:外部导入] 题目描述 1 ...
- 【USACO】Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer b ...
- Milking Cows 挤牛奶
1.2.1 Milking Cows 挤牛奶 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 554 Solved: 108[Submit][Status ...
- 【洛谷P1204】【USACO1.2】挤牛奶Milking Cows
P1204 [USACO1.2]挤牛奶Milking Cows 题目描述 三个农民每天清晨5点起床,然后去牛棚给3头牛挤奶.第一个农民在300秒(从5点开始计时)给他的牛挤奶,一直到1000秒.第二个 ...
- Milking Cows
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...
- POJ-2528 Mayor's posters (线段树区间更新+离散化)
题目分析:线段树区间更新+离散化 代码如下: # include<iostream> # include<cstdio> # include<queue> # in ...
- 洛谷P1204 [USACO1.2]挤牛奶Milking Cows
P1204 [USACO1.2]挤牛奶Milking Cows 474通过 1.4K提交 题目提供者该用户不存在 标签USACO 难度普及- 提交 讨论 题解 最新讨论 请各位帮忙看下程序 错误 ...
- UVa 1640 The Counting Problem (数学,区间计数)
题意:给定两个数m, n,求从 m 到 n 中0-9数字各出现了多少次. 析:看起来挺简单的,其实并不好做,因为有容易想乱了.主要思路应该是这样的,分区间计数,先从个位进行计,一步一步的计算过来.都从 ...
- codeforce ---A. Milking cows
A. Milking cows time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- 在Windows Server2016中安装SQL Server2016(转)
在Windows Server2016中安装SQL Server2016(转) 转自: http://blog.csdn.net/yenange/article/details/52980135 参考 ...
- Golang 标准库log的实现
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://gotaly.blog.51cto.com/8861157/1406905 前 ...
- 使用java.util.Properties工具制作自定义访问配置文件信息
import ch.qos.logback.classic.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; im ...
- json类型的相互转化
package com.test.jsontest; import java.io.File; import java.io.FileInputStream; import java.io.FileN ...
- tomcat 相关异常
端口没有被占用却提示Several ports (8005, 8080, 8009) required by Tomcat??? 解决办法:1.运行cmd进入命令行界面:2.运行命令: netsh w ...
- UVA 10242 Fourth Point
题意:给你平行四边形两条边的顶点,让你求第四个点. 思路:要找到俩边的公共点,然后向量运算. AC代码: #include<cstdio> #include<cmath> #i ...
- 拾遗:关于“尾递归”- tail recursion
定义[个人理解]: 尾递归,即是将外层得出的常量计算因子,以函数参数的形式逐层向内传递,即内层调用整合外层调用的产出,整个递归的结果最终由最内层的一次函数调用得出:而通常的递归则是外层调用阻塞.等待内 ...
- CM 安装CDH 错误: 安装失败。 无法接收 Agent 发出的检测信号。
在安装CDH的时候出现错误提示: 安装失败. 无法接收 Agent 发出的检测信号. 日志提示错误: start >> raise socket.error(msg) >>er ...
- awesome mac
https://proxyman.app/ https://proxie.app/docs/#how-does-it-work https://github.com/kyleduo/TinyPNG4M ...
- 通过字体代替图片优化,如何使用Font Awesome字体图标?
博客搬迁,给你带来的不便敬请谅解! http://www.suanliutudousi.com/2017/10/17/%E9%80%9A%E8%BF%87%E5%AD%97%E4%BD%93%E4%B ...