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 ...
随机推荐
- ESP8266 LUA脚本语言开发: 外设篇-定时器,延时,看门狗
https://nodemcu.readthedocs.io/en/master/modules/tmr/ local mytimer1 = tmr.create() function TimeFun ...
- C语言第2
今个那老哥替我刷题,然后遇到一个打印中文编码得问题,我多嘴一问,为啥 用 unsiged 然后他让我换成char试试:然后出现了以下结果 #include <stdio.h> #inclu ...
- sql 合并结果集数据
起因:项目上查询一些数据,需要将查询后的结果合并到一列中. 1.STUFF函数 官方api: https://docs.microsoft.com/zh-cn/sql/t-sql/functions/ ...
- 从零开始实现放置游戏(六)——实现后台管理系统(4)Excel批量导入
前面我们已经实现了在后台管理系统中,对配置数据的增删查改.但每次添加只能添加一条数据,实际生产中,大量数据通过手工一条一条添加不太现实.本章我们就实现通过Excel导入配置数据的功能.这里我们还是以地 ...
- QT+OpenGL(01)--实现三角形渲染
1.openglwidget.ui <ui version="4.0"> <author/> <comment/> <exportmacr ...
- cmd 运行bcp 提示:'bcp' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
这个问题的原因是:bcp.exe文件的路径不在环境变量中, 我的环境:Windows10 ,SQL server2016(D:) 1.首先查找你的SQL Server2016的安装位置 找到快捷方式, ...
- jQuery遍历 - 过滤first(),last()和eq()使用
jQuery遍历 - 过滤最基本的过滤方法是first(),last()和eq(),它们允许您根据元素在一组元素中的位置选择特定元素. 其他过滤方法(如filter()和not())允许您选择与特定条 ...
- javascript 关于赋值、浅拷贝、深拷贝的个人理解
关于赋值.浅拷贝.深拷贝,以前也思考良久,很多时候都以为记住了,但是,我太难了.今天我特地写下笔记,希望可以完全掌握这个东西,也希望可以帮助到任何想对学习这个东西的同学. 一.栈.堆.指针地址 栈内存 ...
- 深入理解Vue组件3大核心概念
摘要: 搞懂Vue组件! 作者:浪里行舟 原文:详解vue组件三大核心概念 Fundebug经授权转载,版权归原作者所有. 前言 本文主要介绍属性.事件和插槽这三个vue基础概念.使用方法及其容易被忽 ...
- vue.js 父组件主动获取子组件的数据和方法、子组件主动获取父组件的数据和方法
父组件主动获取子组件的数据和方法 1.调用子组件的时候 定义一个ref <headerchild ref="headerChild"></headerchild& ...