bzoj1623 [Usaco2008 Open]Cow Cars 奶牛飞车
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.
看到那么多大神都做了这题……我也去写
贪心……排序一下显然速度小的要先合并
自然而然的想到了平衡树……(不要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);
}
bzoj1623 [Usaco2008 Open]Cow Cars 奶牛飞车的更多相关文章
- 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 ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- BZOJ——1623: [Usaco2008 Open]Cow Cars 奶牛飞车
http://www.lydsy.com/JudgeOnline/problem.php?id=1623 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 6 ...
- 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 ...
- [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 ...
随机推荐
- AJAX实例入门
一.开门见山 这些时间,瞎子也看得见,AJAX正大踏步的朝我们走来.不管我们是拥护也好,反对也罢,还是视而不见,AJAX像一阵潮流,席转了我们所有的人. 关于AJAX的定义也好,大话也好,早有人在网上 ...
- 数据结构之顺序表,c#实现
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using S ...
- UESTC_方老师和农场 2015 UESTC Training for Graph Theory<Problem L>
L - 方老师和农场 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- SqlServer 查询表、表说明、关联表、字段说明,语句汇总
----查询所有的表 SELECT * FROM SYSOBJECTS WHERE TYPE='U' ----根据表名查询所有的字段名及其注释 SELECT A.NAME,B.VALUE FROM S ...
- poj 3685 Matrix(二分搜索之查找第k大的值)
Description Given a N × N matrix A, whose element × i + j2 - × j + i × j, you are to find the M-th s ...
- 修改UITextField placeholder Color
[YourtextField setValue:[UIColor colorWithRed:97.0/255.0 green:1.0/255.0 blue:17.0/255.0 alpha:1.0] ...
- 用Visual Studio2010 编译 C++文件"hello world”
本周开始学习C++语言,用Visual Studio 2010做编译器,发现站内还没有基础的关于用VS2010编译程序的教材.而且自己在网上寻找时候,教程难找,而且大都不详细.故写一个关于这方面的教程 ...
- Linux下redis的安装及用法
1.下载源代码包redis-2.8.21.tar.gz,并将其上传到指定文件夹/urs/src,然后对其进行解压: [root@Slave1pc src]# tar -xvf redis-2.8.21 ...
- VS2012 拆分视图按钮不见,代码,设计
工具--选项--HTML设计器 然后重启就有了.
- SQLserver 连接+开窗函数+视图+事务
今天学习SQLserver 连接以及开窗函数..加油! 1.复习:查询(检索)->筛选列->筛选行:distinct top where 运算符与关键字:比较运算符,逻辑运算符,betwe ...