3893: [Usaco2014 Dec]Cow Jog
3893: [Usaco2014 Dec]Cow Jog
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 174 Solved: 87
[Submit][Status][Discuss]
Description
The cows are out exercising their hooves again! There are N cows jogging on an infinitely-long single-lane track (1 <= N <= 100,000). Each cow starts at a distinct position on the track, and some cows jog at different speeds. With only one lane in the track, cows cannot pass each other. When a faster cow catches up to another cow, she has to slow down to avoid running into the other cow, becoming part of the same running group. The cows will run for T minutes (1 <= T <= 1,000,000,000). Please help Farmer John determine how many groups will be left at this time. Two cows should be considered part of the same group if they are at the same position at the end of T minutes.
在一条无限长的跑道上有N头牛,每头牛有自己的初始位置及奔跑的速度。牛之间不能互相穿透。当一只牛追上另一只牛时,它不得不慢下来,成为一个群体。求T分钟后一共有几个群体。
Input
Output
Sample Input
0 1
1 2
2 3
3 2
6 1
Sample Output
HINT
Source
题解:显然,一头牛的速度不会被后面的牛所影响,于是直接O(n)扫一遍,像打擂台一样即可,这样子分堆数也就出来啦
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n,ans:longint;
a,b:array[..] of longint;
t:int64;
begin
readln(n,t);
for i:= to n do readln(a[i],b[i]);
a[n+]:=maxlongint;
b[n+]:=maxlongint;
l:=n+;
for i:=n downto do
begin
if (a[i]+(b[i]*t))<(a[l]+(b[l]*t)) then
begin
inc(ans);
l:=i;
end;
end;
writeln(ans);
end.
3893: [Usaco2014 Dec]Cow Jog的更多相关文章
- Bzoj3893 [Usaco2014 Dec]Cow Jog
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 302 Solved: 157 Description The cows are out exerci ...
- [bzoj3893][Usaco2014 Dec]Cow Jog_暴力
Cow Jog bzoj-3893 Usaco-2014 Dec 题目大意:题目链接. 注释:略. 想法: 先按照坐标排序. 我们发现每个牛只会被后面的牛影响. 所以我们考虑逆向枚举. 记录一下i+1 ...
- 3892: [Usaco2014 Dec]Marathon
3892: [Usaco2014 Dec]Marathon Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 169 Solved: 100[Submi ...
- Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 554 Solved: 346[ ...
- BZOJ 1649: [Usaco2006 Dec]Cow Roller Coaster( dp )
有点类似背包 , 就是那样子搞... --------------------------------------------------------------------------------- ...
- BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐( dfs )
直接从每个奶牛所在的farm dfs , 然后算一下.. ----------------------------------------------------------------------- ...
- BZOJ 3446: [Usaco2014 Feb]Cow Decathlon( 状压dp )
水状压dp. dp(x, s) = max{ dp( x - 1, s - {h} ) } + 奖励(假如拿到的) (h∈s). 时间复杂度O(n * 2^n) ------------------- ...
- 3891: [Usaco2014 Dec]Piggy Back
3891: [Usaco2014 Dec]Piggy Back Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 116 Solved: 92[Subm ...
- 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 432 Solved: 270[ ...
随机推荐
- JSP编译为Java类
JSP编译为Java类: 注意可以随便写import的内容:可以写类属性.方法.main函数.内部类:可以使用内部类: JSP: <%@ page language="java&quo ...
- 车大棒浅谈for循环+canvas实现黑客帝国矩形阵
背景: 一日在网上闲逛的之时,突然看到一个利用JQ插件实现canvas实现的电影黑客帝国的小Demo.觉得创意不错,就下载下来研究一下. 网上浏览jQuery的写法 $(document).ready ...
- Linux笔记(三) - 文件搜素
(1)文件搜索:find-name 根据文件名, *匹配任意字符 ,?单个字符-iname 根据文件名, 不区分大小写-size 根据文件大小查找 (+ 大于 -小于)(-a并且 -o或者)-us ...
- jquery 全选 全不选 事件绑定
<td width="82%" colspan="3"><input type="checkbox" id="a ...
- HDU1716(全排列)
排列2 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Oracle 11g 的安装及配置详解
一.安装前的准备: 首先在这里给出本人的百度网盘的链接:http://pan.baidu.com/s/1c1WF1PQ:网速快的小伙伴建议到官网:http://www.oracle.com/techn ...
- [JQuery]Jquery对象和dom对象
jquery对象是jquery包装dom对象后产生的对象,它们都只能使用各自的方法. 1.定义变量时,通过$来区分: var $variable = jquery对象: var variable = ...
- Android实现屏蔽微信拉黑和删除联系人功能
实现效果: 让微信永远弹不出那个删除的对话框不就相当于屏蔽掉该功能了吗?哈哈效果如图: 实现原理: 同样是利用AccessibilityService辅助服务,关于这个服务类还不了解的同学可以先看下我 ...
- 获取SQL中某一列的类型及精度
SELECT @type=t.name, @prec=c.prec FROM sysobjects o JOIN syscolumns c on o.id=c.id JOI ...
- iOS获取本地时间
NSDate *currentDate = [NSDate date];//获取当前时间,日期 NSDateFormatter *dateFormatter = [[NSDateFormatter a ...