洛谷 P2909 [USACO08OPEN]牛的车Cow Cars
题目大意:
m个车道。
如果第i头牛前面有k头牛,那么这头牛的最大速度会
变为原本的速度-k*D,如果速度小于l这头牛就不能行驶。
题解:贪心
让初始速度小的牛在前面
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 50009
using namespace std; int n,m,d,l,k,ans; int a[N],cnt[N]; 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<=n;i++){
for(int j=;j<=m;j++){
int tmp=a[i]-d*cnt[j];
if(tmp>=l){
ans++;
cnt[j]++;
break;
}
}
}
cout<<ans<<endl;
return ;
}
洛谷 P2909 [USACO08OPEN]牛的车Cow Cars的更多相关文章
- bzoj1623 / P2909 [USACO08OPEN]牛的车Cow Cars
P2909 [USACO08OPEN]牛的车Cow Cars 显然的贪心. 按速度从小到大排序.然后找车最少的车道,查询是否能填充进去. #include<iostream> #inclu ...
- 洛谷 P2906 [USACO08OPEN]牛的街区Cow Neighborhoods | Set+并查集
题目: https://www.luogu.org/problemnew/show/P2906 题解: 垃圾水题 #include<cstdio> #include<algorith ...
- [USACO08OPEN]牛的车Cow Cars
题目描述 N (1 <= N <= 50,000) cows conveniently numbered 1..N are driving in separate cars along a ...
- 洛谷P3080 [USACO13MAR]牛跑The Cow Run
P3080 [USACO13MAR]牛跑The Cow Run 题目描述 Farmer John has forgotten to repair a hole in the fence on his ...
- 洛谷——P2853 [USACO06DEC]牛的野餐Cow Picnic
P2853 [USACO06DEC]牛的野餐Cow Picnic 题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ ...
- 洛谷 P2853 [USACO06DEC]牛的野餐Cow Picnic
P2853 [USACO06DEC]牛的野餐Cow Picnic 题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ ...
- 洛谷P2853 [USACO06DEC]牛的野餐Cow Picnic
题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N ...
- 洛谷 3029 [USACO11NOV]牛的阵容Cow Lineup
https://www.luogu.org/problem/show?pid=3029 题目描述 Farmer John has hired a professional photographer t ...
- 洛谷 P2966 [USACO09DEC]牛收费路径Cow Toll Paths
题目描述 Like everyone else, FJ is always thinking up ways to increase his revenue. To this end, he has ...
随机推荐
- 20145109 《Java程序设计》第六周学习总结
Chapter 10 I/O 10.1 InputStream & OutputStream a new 'try' edition: try (InputStream input = src ...
- WIN7下PHP无法开启CURL,终极解决方案
常规做法: 1)extension=php_curl.dll之外 2)把libeay32.dll.ssleay32.dll.php_curl.dll复制到C:\Windows\SysWOW64目录下 ...
- DataStage 服务启动
说明:①如果发现was.datastage已经自启动,但db2没有自启动,应先将它们停止,在按顺序启动;②如果都自启动了,就不用再启动,关闭防火墙即可. --0.关闭防火墙service iptabl ...
- Android各种屏幕分辨率(VGA、HVGA、QVGA、WQVGA、WVGA、FWVGA) 详解 .
http://blog.csdn.net/lucherr/article/details/8498400 看资料的时候经常看到各种VGA,全都混了,无奈,找了些资料总结了下,分享给大家: 这些术语都是 ...
- JSON和GSON的使用
JSONObject 处理问题 相关博客参考:https://www.cnblogs.com/free-dom/p/5801866.html json-lib 和google gson 的使用 Tor ...
- vector push_back数量大的时候变慢
才用15000个数据 push_back耗时就好几秒, 解决方法是 先resize 15000, 然后再 for (int i = 0; i < 15000; i++) { Data data ...
- http Code含义
5xx - 服务器错误 服务器由于遇到错误而不能完成该请求.
- 【sparkStreaming】kafka作为数据源的生产和消费
1.建立生产者发送数据 (1)配置zookeeper属性信息props (2)通过 new KafkaProducer[KeyType,ValueType](props) 建立producer (3) ...
- 剑指offer--36.整数中1出现的次数(从1到n整数中1出现的次数)
暴力挨个数 ---------------------------------------------------------------------- 时间限制:1秒 空间限制:32768K 热度指 ...
- New Concept English three (40)
23w/m 48 errors It has never been explained why university students seem to enjoy practical jokes mo ...