Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends at time 1200. The third farmer begins at time 1500 and ends at time 2100. The longest continuous time during which at least one farmer was milking a cow was 900 seconds (from 300 to 1200). The longest time no milking was done, between the beginning and the ending of all milking, was 300 seconds (1500 minus 1200).
Your job is to write a program that will examine a list of beginning and ending times for N (1 <= N <= 5000) farmers milking N cows and compute (in seconds):
- The longest time interval at least one cow was milked.
- The longest time interval (after milking starts) during which no cows were being milked.
PROGRAM NAME: milk2
INPUT FORMAT
Line 1: | The single integer |
Lines 2..N+1: | Two non-negative integers less than 1000000, the starting and ending time in seconds after 0500 |
SAMPLE INPUT (file milk2.in)
3
300 1000
700 1200
1500 2100
OUTPUT FORMAT
A single line with two integers that represent the longest continuous time of milking and the longest idle time.
SAMPLE OUTPUT (file milk2.out)
900 300
/*
ID:qhn9992 PROG:milk2 LANG:C++ */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; int ran[1000010],a,b,t,st=0,milking,idle,ans1,ans2; int main() cin>>t;int start=999999999,end=-99999999; |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
Milking Cows的更多相关文章
-
洛谷P1204 [USACO1.2]挤牛奶Milking Cows
P1204 [USACO1.2]挤牛奶Milking Cows 474通过 1.4K提交 题目提供者该用户不存在 标签USACO 难度普及- 提交 讨论 题解 最新讨论 请各位帮忙看下程序 错误 ...
-
codeforce ---A. Milking cows
A. Milking cows time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
-
【题解】Luogu P1204 [USACO1.2]挤牛奶Milking Cows
原题传送门:P1204 [USACO1.2]挤牛奶Milking Cows 实际是道很弱智的题目qaq 但窝还是觉得用珂朵莉树写会++rp(窝都初二了,还要考pj) 前置芝士:珂朵莉树 窝博客里对珂朵 ...
-
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 挤牛奶 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 ...
-
USACO Section 1.2 Milking Cows 解题报告
题目 题目描述 有3个农夫每天早上五点钟便起床去挤牛奶,现在第一个农夫挤牛奶的时刻为300(五点钟之后的第300个分钟开始),1000的时候结束.第二个农夫从700开始,1200结束.最后一个农夫从1 ...
-
洛谷 P1204 [USACO1.2]挤牛奶Milking Cows Label:模拟Ex 74分待查
题目描述 三个农民每天清晨5点起床,然后去牛棚给3头牛挤奶.第一个农民在300秒(从5点开始计时)给他的牛挤奶,一直到1000秒.第二个农民在700秒开始,在 1200秒结束.第三个农民在1500秒开 ...
随机推荐
-
SharePoint Online 创建门户网站系列之母版页
前 言 虽然SharePoint中母版页看起来只是头部Banner和底部版权信息这两个部分,但是实质在SharePoint Online中的页面模型中占有重要地位,而且SPO对母版页有着完善的签入签出 ...
-
mysql锁表机制及相关优化
(该文章为方便自己查阅,也希望对大家有所帮助,转载于互联网) 1. 锁机制 当前MySQL支持 ISAM, MyISAM, MEMORY (HEAP) 类型表的表级锁,BDB 表支持页级锁,InnoD ...
-
iOS开发——总结篇&;常用开发总结
一.通知1.监听通知 - (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(i ...
-
Largest Rectangle in a Histogram HDU - 1506 (单调栈)
A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rec ...
-
[LibreOJ #2983]【WC2019】数树【计数】【DP】【多项式】
Description 此题含有三个子问题 问题1: 给出n个点的两棵树,记m为只保留同时在两棵树中的边时连通块的个数,求\(y^m\) 问题2: 给出n个点的一棵树,另外一棵树任意生成,求所有方案总 ...
-
SaltStack之Salt-ssh
上一篇:SaltStack远程执行-返回MySQL 通常salt需要在客户端安装salt-minion使用salt-ssh可以在客户断主机免安装minion 在master主机安装salt-ssh y ...
-
代码题 — 剑指offer题目、新增题目
1.剪绳子 给你一根长度为n的绳子,请把绳子剪成m段 (m和n都是整数,n>1并且m>1)每段绳子的长度记为k[0],k[1],...,k[m].请问k[0]*k[1]*...*k[m] ...
-
list array解析(总算清楚一点了)
# -*- coding: utf-8 -*- """ Created on Tue Aug 09 23:04:51 2016 @author: Administrato ...
-
[转] Makefile 基础 (9) —— Makefile 使用make更新函数库文件
该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神博客:(最原始版本) http://blog.csdn.net/haoel/article/details/2886 我转自 ...
-
suseoj 1206 众数问题 (相邻数比较)
1206: 众数问题 时间限制: 1 Sec 内存限制: 128 MB提交: 45 解决: 8[提交][状态][讨论版][命题人:liyuansong] 题目描述 给定含有n个元素的多重集合S,每 ...