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[ ...
随机推荐
- lo dash api
https://lodash.com/docs 用 Lo-Dash 替换 underscore http://segmentfault.com/a/1190000000359484
- C# WINFORM ListView用法详解(转)
源代码下载位置: http://pan.baidu.com/s/1qXrLehe 一.ListView类 1.常用的基本属性: (1)FullRowSelect:设置是否行选择模式.(默认为false ...
- Sql Server 查询多行并一行
干货 CREATE TABLE #benefit_code21 (id INT, number nvarchar(MAX), pname ), collegeID INT, applicationda ...
- jackson - 生成jason工具-简单示例
主页: http://jackson.codehaus.org/ https://github.com/FasterXML/jackson 当前jackson分为三部分,需要分别下载: jackson ...
- 关于Visual Studio未能加载各种Package包的解决
参考微软社区的一个答复解决了VS2013的问题: 进入VS对应的用户缓存文件夹,删掉那个Microsoft.VisualStudio.Default.cache缓存文件,就可以了. 这个错误估计是我们 ...
- Centos6.5 mysql折腾记
1.yum安装mysql [root@localhost ~]# yum -y install mysql-server 安装结果 Installed: mysql-server.x86_64 0:5 ...
- 基于UDP协议的socket通信
服务器端: 1.创建DatagramSocket,指定端口号 2.创建DatagramPacket 3.接收客户端发送的数据信息 4.读取数据 客户端: 1.定义发送信息 2.创建DatagramPa ...
- setTimeout小总结
▓▓▓▓▓▓ 大致介绍 今天看了一篇文章,觉得写得不错,所以学习了一下,这篇博客是我自己的理解和总结 原文:你应该知道的 setTimeout 秘密 主要内容: 1.setTimeout原理 2.se ...
- redisson实现分布式锁原理
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- springmvc注解式事务手动回滚
Spring的AOP事务管理默认是针对unchecked exception回滚(运行期异常,Runtime Exception),如果希望手动控制事务的回滚,可以通过 TransactionAspe ...