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 ...
随机推荐
- 3. 初识jmeter及JDK安装
jmeter 介绍 Apache JMeter™应用程序是开源软件,100%纯Java应用程序,旨在加载测试功能行为和测量性能.它最初是为测试Web应用程序而设计的,但后来扩展到其他测试功能. Jme ...
- PAT_A1023#Have Fun with Numbers
Source: PAT A1023 Have Fun with Numbers (20 分) Description: Notice that the number 123456789 is a 9- ...
- 网络编程(二)——TCP协议、基于tcp协议的套接字socket
TCP协议与基于tcp协议的套接字socket 一.TCP协议(流式协议) 1.可靠传输,TCP数据包没有长度限制,理论上可以无限长,但是为了保证网络的效率,通常TCP数据包的长度不会超过IP数据包的 ...
- react map循环数据 死循环
项目条件:react es6 antidesign 已在commonState中获取到list,但是在循环map填充DOM的时候陷入死循环. 原因:因为是子组件 ,在父组件请求数据的时候 有个时差过程 ...
- touchWX 自定义组件以及传值
创建如图文件 index.wxc: <template> <view class="wx-test" bindtap="handleTap"& ...
- The J2EE Architecture
- 二.Python基础语法和数据类型
Python第二节 基础语法和数据类型 Python编码 python3默认情况下源码文件以UTF-8编码, 字符串均为unicode字符串.同时也可以通过# -*- coding: cp-1252 ...
- 22-3concat
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 前端 JavaScript BOM & DOM
内容目录: 1. BOM 2. DOM BOM(Browser Object Model)是指浏览器对象模型,它使 JavaScript 有能力与浏览器进行"对话". DOM (D ...
- No package docker-io available
新手centos6.8安装docker时从遇到No package docker-io available开始的各种不小心的坑... 新安装了CentOS6.8,准备安装docker,执行命令 yum ...