BZOJ——1623: [Usaco2008 Open]Cow Cars 奶牛飞车
2024-09-29 11:38:33
http://www.lydsy.com/JudgeOnline/problem.php?id=1623
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 624 Solved: 433
[Submit][Status][Discuss]
Description
编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有M(1≤M≤N)条车道.奶牛i有一个自己的车速上限Si(l≤Si≤1,000,000).
在经历过糟糕的驾驶事故之后,奶牛们变得十分小心,避免碰撞的发生.每条车道上,如果某一只奶牛i的前面有K只奶牛驾车行驶,那奶牛i的速度上限就会下降K*D个单位,也就是说,她的速度不会超过Si - kD(O≤D≤5000),当然如果这个数是负的,那她的速度将是0.牛德比亚的高速会路法规定,在高速公路上行驶的车辆时速不得低于/(1≤L≤1,000,000).那么,请你计算有多少奶牛可以在高速公路上行驶呢?
Input
第1行输入N,M,D,L四个整数,之后N行每行一个整数输入Si.
N<=50000
Output
输出最多有多少奶牛可以在高速公路上行驶.
Sample Input
3 1 1 5//三头牛开车过一个通道.当一个牛进入通道时,它的速度V会变成V-D*X(X代表在它前面有多少牛),它减速后,速度不能小于L
5
7
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.
HINT
Source
优先队列存储每条道路上的人数,每头牛判断能否在加在最少人数的道路上
#include <algorithm>
#include <cstdio>
#include <queue> using namespace std; inline void read(int &x)
{
x=; register char ch=getchar();
for(; ch>''||ch<''; ) ch=getchar();
for(; ch>=''&&ch<=''; ch=getchar()) x=x*+ch-'';
} const int N(5e4+); int n,m,d,l,ans,s[N]; priority_queue<int,vector<int>,greater<int> >que; int Presist()
{
read(n),read(m), read(d),read(l);
for(int i=; i<=n; ++i) read(s[i]);
sort(s+,s+n+);
for(int i=; i<=m; ++i) que.push();
for(int u,i=; i<=n; ++i)
{
u=que.top();
if(s[i]-u*d>=l)
ans++,que.pop(),
que.push(++u);
}
printf("%d\n",ans);
return ;
} int Aptal=Presist();
int main(int argc,char**argv){;}
最新文章
- scrapy数据存入mongodb
- 关于MySQL的Admin Ping Command
- 当年的文曲星cc800
- 图解傅里叶变换(so easy)
- LPSTR、LPCSTR、LPWSTR、LPCWSTR、LPTSTR、LPCTSTR的来源及意义
- Extjs ajax form 提交
- A Simple Actions Recognition System
- Clean Code &ndash; Chapter 6 Objects and Data Structures
- ECMall的MySQL数据调用的简单方法
- [置顶] 浅析objc的消息机制
- xfs文件系统磁盘配额
- 根据字符串获取对应类型(Type) 转
- ios 初体验<;真机调试>;
- .NET Core 从 Github到 Nuget 持续集成、部署
- Springboot 框架学习
- DataStructure-链表实现指数非递减一元多项式的求和
- Codeforces 1132G Greedy Subsequences [线段树]
- GradleUserGuide中文版 19)Plugins 20)插件规范 21)Java插件
- 解决SQL Server 2008安装时提示:重新启动计算机 失败
- OnlineJudgeFE之前端二次开发
热门文章
- ccf 201803-1 跳一跳(Python实现)
- 【TCP/IP】【网络基础】网页访问流程
- 【kindle】【转发】kindle链接WIFI自动断开问题
- XML映射文件中关系映射
- Linux学习-systemctl 针对 service 类型的配置文件
- 大家好,我是一个JAVA初学者,想在这里记下自己学习过程中的点点滴滴,请多多关照
- 《Scrum实战》第3次课【富有成效的每日站会】作业汇总
- Selenium WebDriver-操作下拉框内容
- TensorFlow TFRecord封装不定长的序列数据(文本)
- [转]how to inserting multiple rows in one step