bzoj1623 [Usaco2008 Open]Cow Cars 奶牛飞车
2024-09-27 09:10:26
Description
编号为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).那么,请你计算有多少奶牛可以在高速公路上行驶呢?
Input
第1行输入N,M,D,L四个整数,之后N行每行一个整数输入Si.
Output
输出最多有多少奶牛可以在高速公路上行驶.
Sample Input
3 1 1 5//三头牛开车过一个通道.当一个牛进入通道时,它的速度V会变成V-D*X(X代表在它前面有多少牛),它减速后,速度不能小于L
5
7
5
INPUT DETAILS:
There are three cows with one lane to drive on, a speed decrease
of 1, and a minimum speed limit of 5.
5
7
5
INPUT DETAILS:
There are three cows with one lane to drive on, a speed decrease
of 1, and a minimum speed limit of 5.
Sample Output
2
OUTPUT DETAILS:
Two cows are possible, by putting either cow with speed 5 first and the cow
with speed 7 second.
OUTPUT DETAILS:
Two cows are possible, by putting either cow with speed 5 first and the cow
with speed 7 second.
看到那么多大神都做了这题……我也去写
贪心……排序一下显然速度小的要先合并
自然而然的想到了平衡树……(不要D我)
但是黄巨大说直接每次需按人数最少的加进去就好了
当然我这sillycross想不到这么精妙的做法
#include<cstdio>
#include<algorithm>
using namespace std;
int v[50010];
int n,m,d,l,forward,ans;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main()
{
n=read();m=read();d=read();l=read();
for (int i=1;i<=n;i++)
v[i]=read();
sort(v+1,v+n+1);
for (int i=1;i<=n;i++)
{
forward=ans/m;
if (v[i]-forward*d>=l)ans++;
}
printf("%d",ans);
}
最新文章
- Code First 迁移,及迁移错误
- VS2015调试UWP程序时提示错误DEP0700 : Registration of the app failed. Another user has already installed
- Android 中Thread,Handler,Loop学习
- cocos2dx3.4 保存json文件
- [一道搜狗输入法的面试题]C++转换构造函数和类型转换函数
- 为什么做Web开发要选择PHP
- [iOS Animation]-CALayer 图层性能
- 模态Model视图Push下一个视图(混合跳转)
- 2017寒假零基础学习Python系列之 印子
- Shell中数组的使用
- AJAX-同源策略 跨域访问
- n个骰子的点数之和
- maven source 1.3 中不支持泛型 解决办法
- JSP页面使用include指令出现 Duplicate local variable basePath
- 入门项目 A5-3 interface-user 第三方接口3
- 雷林鹏分享:现实生活中的 XML
- Project configuration is not up-to-date with pom.xml
- 如何计算 App 的启动时间
- spark sql中保存数据的几种方式
- ElasticSearch学习之——基本的文档CURD
热门文章
- MLC固态硬盘,与入量是3000次P/E
- Sum Root to Leaf Numbers 解答
- 关于UIButton中的ContentEdgeInsets的深入研究
- jquery ajax 局部table 刷新技术
- UITableView 自定义选中Cell颜色
- dispatch_group_async
- Eclipse 里的 Classpath Variables M2_REPO 无法修改(maven)
- Exchange Server 2010升级到Exchange Server 2013概览
- IOS 怎么修改Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色
- 同一DataTable下创建多个结构数据相同的DataView的小问题