【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了。。。
最小道路=已选取的奶牛/道路总数。
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int v[];
int n,m,d,l,ans;
int main()
{
scanf("%d%d%d%d",&n,&m,&d,&l);
for (int i=;i<=n;i++) scanf("%d",&v[i]);
sort(v+,v+n+);
for (int i=;i<=n;i++)
{
int t=ans/m;
if (v[i]-t*d>=l) ans++;
}
printf("%d",ans);
return ;
}
Description
Input
Output
Sample Input
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
OUTPUT DETAILS:
Two cows are possible, by putting either cow with speed 5 first and the cow
with speed 7 second.
HINT
Source
【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心的更多相关文章
- bzoj1623 [Usaco2008 Open]Cow Cars 奶牛飞车
Description 编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有M(1≤M≤N)条车道.奶牛i有一个自己的车速上限Si(l≤Si≤1,000,000). ...
- 1623: [Usaco2008 Open]Cow Cars 奶牛飞车
1623: [Usaco2008 Open]Cow Cars 奶牛飞车 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 291 Solved: 201[S ...
- bzoj 1623: [Usaco2008 Open]Cow Cars 奶牛飞车
1623: [Usaco2008 Open]Cow Cars 奶牛飞车 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 325 Solved: 223[S ...
- BZOJ 1623 [Usaco2008 Open]Cow Cars 奶牛飞车:贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1623 题意: 编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有 ...
- bzoj 1623: [Usaco2008 Open]Cow Cars 奶牛飞车【排序+贪心】
从小到大排个序,然后能选就选 #include<iostream> #include<cstdio> #include<algorithm> using names ...
- BZOJ——1623: [Usaco2008 Open]Cow Cars 奶牛飞车
http://www.lydsy.com/JudgeOnline/problem.php?id=1623 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 6 ...
- [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
[BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 试题描述 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发 ...
- BZOJ1612: [Usaco2008 Jan]Cow Contest奶牛的比赛
1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 645 Solved: 433 ...
- Bzoj 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 传递闭包,bitset
1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 891 Solved: 590 ...
随机推荐
- U3D学习笔记1: HelloWorld
Unity 版本: 5.3.5.f1 Hello World工程 1.新建工程 HelloWorld U3D可选2D和3D游戏 2.新建C#脚本文件 在project栏的assets目录右键-&g ...
- iOS Swift的一些小知识(不断补充)
1. 在swift文件里是不能写c语言函数的,不兼容c,直接报错.想调用c语言函数,就要利用系统提供的桥接功能,就如同swfit中调用oc一样! 2.swift 2.0后提供了@convention( ...
- 设计模式--装饰模式Decorate(结构型)
一.装饰模式 动态地给一个对象添加额外的职责.就增加功能来说,装饰模式相比生成子类更为灵活.有时我们希望给某个对象而不是整个类添加一些功能. 二.UML图 1.Component(概念中提到的对象接口 ...
- 下载旧版本的NDK
在官网找不到旧版本的下载地址,只能取巧了. 写该随笔的时候,NDK最新的版本是r12,见 https://developer.android.com/ndk/downloads/index.html# ...
- marquee实现文字移动效果;js+div实现文字无缝移动效果
1.marquee实现文字移动: <marquee width="220px;" scrollamount="5" onmouseover="t ...
- 【mongo】mongoVUE使用
1.查询存在字段"test"的项 {"test":{$exists:true}} 2.在表中插入字段 {$set:{"}} 3.正则匹配 {" ...
- OpenGL glMultMatrixf() glPushMatrix() glPushMatrix()浅析
我在之前的博客中曾提到过,OpenGL中坐标是采用行向量表示的,与之相对应的是,在矩阵变换中使用的是变换矩阵的转置,并且使用的是后乘的方式.本文直接使用下面的代码来及其后的图示来解释函数 p,li { ...
- 使用keychain保存用户名和密码等敏感信息 KeychainItemWrapper和SFHFKeychainUtils
iOS的keychain服务提供了一种安全的保存私密信息(密码,序列号,证书等)的方式,每个ios程序都有一个独立的keychain存储.相对于 NSUserDefaults.文件保存等一般方式,ke ...
- java回调机制
http://www.cnblogs.com/heshuchao/p/5376298.html
- 禁止换行“white-space:nowrap;”!
"white-space:nowrap;" <html> <div class="box">精彩的生活,精彩的世界</div> ...