洛谷 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 ...
随机推荐
- html5 canvas js(时钟)
<!doctype html> <html> <head> <title>canvas</title> </head> < ...
- 高亮显示QSS文件
转[作者:一去丶二三里 博客地址:http://blog.csdn.net/liang19890820] 简述 语法高亮是文本编辑器用来显示文本的,特别是源代码,根据不同的类别来用不同的颜色和字体显示 ...
- android timed gpio (linux 3.0.0) 受时钟控制的gpio【转】
本文转载自:https://blog.csdn.net/linxi_hnh/article/details/8043417 1 路径: drivers/staging/android/timed_gp ...
- 用JAR的方式运行SpringBoot项目
接 Spring Boot 快速入门(Eclipse) 步骤一:部署方式 Springboot 和 web 应用程序不一样,其本质上是一个 Java 应用程序,那么又如何部署呢? 通常来说,Sprin ...
- 完全理解Android中的RemoteViews
一.什么是RemoteViews RemoteViews翻译过来就是远程视图.顾名思义,RemoteViews不是当前进程的View,是属于SystemServer进程.应用程序与RemoteView ...
- Kubernetes的网络模型
http://blog.csdn.net/zjysource/article/details/52052420
- nrm npm源管理利器
nrm npm源管理利器 nrm是管理npm源的一个利器. 有时候我们用npm install 安装依赖时会非常的慢,是官方自身的npm本来就慢,然后我们会尝试安装淘宝的npm或者cnpm,这些安装切 ...
- MySQL配置管理与安装方法
数据库的安装: 版本:SQL2008 R2(下载地址为:http://www.accessoft.com/article-show.asp?id=11192) 这里说明一下: NT Authority ...
- 智课雅思词汇---二十四、名词性后缀ary(也是形容词后缀)
智课雅思词汇---二十四.名词性后缀ary(也是形容词后缀) 一.总结 一句话总结:很多词缀即是名词词缀也是形容词词缀,很多词即是名词也是形容词 1.名词性后缀-tude? 词根词缀:-tude [来 ...
- spring: @RequestMapping注解
处理GET/POST请求方法 1.常用的: import org.springframework.web.bind.annotation.RequestMapping; @Controller pub ...