USACO Cow Cars
洛谷 P2909 [USACO08OPEN]牛的车Cow Cars
https://www.luogu.org/problemnew/show/P2909
JDOJ 2584: USACO 2008 Open Silver 3.Cow Cars
https://neooj.com:8082/oldoj/problem.php?id=2584
题目描述
N (1 <= N <= 50,000) cows conveniently numbered 1..N are driving in separate cars along a highway in Cowtopia. Cow i can drive in any of M different high lanes (1 <= M <= N) and can travel at a maximum speed of S_i (1 <= S_i <= 1,000,000) km/hour.
After their other bad driving experience, the cows hate collisions and take extraordinary measures to avoid them. On this highway, cow i reduces its speed by D (0 <= D <= 5,000) km/hour for each cow in front of it on the highway (though never below 0 km/hour). Thus, if there are K cows in front of cow i, the cow will travel at a speed of max[S_i - D * K, 0]. While a cow might actually travel faster than a cow directly in front of it, the cows are spaced far enough apart so crashes will not occur once cows slow down as
described,
Cowtopia has a minimum speed law which requires everyone on the highway to travel at a a minimum speed of L (1 <= L <= 1,000,000) km/hour so sometimes some of the cows will be unable to take the highway if they follow the rules above. Write a program that will find the maximum number of cows that can drive on the highway while obeying the minimum speed limit law.
编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有M(1≤M≤N)条车道.奶牛i有一个自己的车速上限Si(l≤Si≤1,000,000).
在经历过糟糕的驾驶事故之后,奶牛们变得十分小心,避免碰撞的发生.每条车道上,如果某一只奶牛i的前面有南只奶牛驾车行驶,那奶牛i的速度上限就会下降kD个单位,也就是说,她的速度不会超过Si – kD(O≤D≤5000),当然如果这个数是负的,那她的速度将是0.牛德比亚的高速会路法规定,在高速公路上行驶的车辆时速不得低于/(1≤L≤1,000,000).那么,请你计算有多少奶牛可以在高速公路上行驶呢?
输入输出格式
输入格式:
* Line 1: Four space-separated integers: N, M, D, and L
* Lines 2..N+1: Line i+1 describes cow i's initial speed with a single integer: S_i
输出格式:
* Line 1: A single integer representing the maximum number of cows that can use the highway
输入输出样例
说明
There are three cows with one lane to drive on, a speed decrease of 1, and a minimum speed limit of 5.
Two cows are possible, by putting either cow with speed 5 first and the cow with speed 7 second.
#include<cstdio>
#include<algorithm>
using namespace std;
int a[];
int n,s,m,d,l,ans;
int main()
{
scanf("%d%d%d%d",&n,&m,&d,&l);
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
sort(a+,a++n);
for(int i=;i<=m;i++)
{
ans=;
for(int j=;j<=n;j++)
{
if(a[j]==)
continue;
if(a[j]-ans*d>=l || (a[j]-ans*d< && l==))
ans++,s++,a[j]=;
}
}
printf("%d",s);
return ;
}
USACO Cow Cars的更多相关文章
- 1623: [Usaco2008 Open]Cow Cars 奶牛飞车
1623: [Usaco2008 Open]Cow Cars 奶牛飞车 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 291 Solved: 201[S ...
- bzoj1623 / P2909 [USACO08OPEN]牛的车Cow Cars
P2909 [USACO08OPEN]牛的车Cow Cars 显然的贪心. 按速度从小到大排序.然后找车最少的车道,查询是否能填充进去. #include<iostream> #inclu ...
- bzoj 1623: [Usaco2008 Open]Cow Cars 奶牛飞车
1623: [Usaco2008 Open]Cow Cars 奶牛飞车 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 325 Solved: 223[S ...
- [USACO08OPEN]牛的车Cow Cars
题目描述 N (1 <= N <= 50,000) cows conveniently numbered 1..N are driving in separate cars along a ...
- USACO Cow Contest
洛谷 P2419 [USACO08JAN]牛大赛Cow Contest https://www.luogu.org/problemnew/show/P2419 JDOJ 2554: USACO 200 ...
- USACO Cow Frisbee Team
洛谷 P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team 洛谷传送门 JDOJ 2632: USACO 2009 Mar Silver 2.Cow Frisbee Team ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- bzoj1623 [Usaco2008 Open]Cow Cars 奶牛飞车
Description 编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有M(1≤M≤N)条车道.奶牛i有一个自己的车速上限Si(l≤Si≤1,000,000). ...
- BZOJ——1623: [Usaco2008 Open]Cow Cars 奶牛飞车
http://www.lydsy.com/JudgeOnline/problem.php?id=1623 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 6 ...
随机推荐
- 前端Vue项目——购物车页面
一.加入购物车的两种策略 1.加入购物车接口 在 src/restful/api.js 中写入添加购物车接口: // 加入购物车的接口 export const shopCart = (params) ...
- 九、Spring之BeanFactory源码分析(一)
Spring之BeanFactory源码分析(一) 注意:该随笔内容完全引自https://blog.csdn.net/u014634338/article/details/82865644,写的 ...
- 设置 VMware 中的 Mac OS 虚拟机进入 Recovery 模式
Ø 简介 本文主要介绍 VMware 中的 Mac OS 虚拟机如何进入 Recovery 模式的方法,具体步骤如下: 1. 选择 Mac OS 虚拟机,点击"打开电源是进入固件&qu ...
- 如何让 FFmpeg 支持异步并行转码、截图等等操作?
直接贴代码了: ffmpegTest02.cs public partial class ffmpegTest02 : FormBase { private static readonly strin ...
- 离线缓存 Visual Studio 2019 (VS2019)的方法
1. 下面是以管理员身份运行命令行: https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-en ...
- 微信小程序小Demo
微信小程序小Demo 调用API,轮播图,排行榜,底部BabTar的使用... board // board/board.js Page({ /** * 页面的初始数据 */ // 可以是网络路径图片 ...
- sqlserver the name is not a valid identifier error in function
参考资料:https://stackoverflow.com/questions/22008859/the-name-is-not-a-valid-identifier-error-in-functi ...
- 【转】Git使用教程之远程仓库
1.远程仓库 在了解之前,先注册github账号,由于你的本地Git仓库和github仓库之间的传输是通过SSH加密的,所以需要一点设置: 第一步:创建SSH Key.在用户主目录下,看看有没有.ss ...
- AccessCenter 模块结构
AccessCenter 模块结构
- Python Scrapy在windows上的安装方法
如果想要学习爬虫,肯定会了解Scrapy,但安装Scrapy的方法相对于安装其他第三方库麻烦一点. 下面总结一下在我的电脑上安装Scrapy的方法,我的电脑是Windows10,32位操作系统.有如下 ...