洛谷 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 ...
随机推荐
- jQuery可自动播放动画的焦点图
在线演示 本地下载
- HTML5抽奖转盘
在线演示 本地下载
- Extracting info from VCF files
R, Bioconductor filterVcf: Extract Variants of Interest from a Large VCF File (Paul Shannon) We demo ...
- DateTime和DateTimeOffset的区别
1,DateTime 表示时间上的一刻,通常以日期和当天时间来表示. 2, DateTimeOffset 表示一个时间点,通常以相对于协调世界时(UTC)的日期和时间来表示. 3,下面是微软官方给出的 ...
- Hibernate -- 一对一映射
一对一关联指两个表之间的记录是一一对应的关系.分为两种:外键关联和主键关联. (1)外键关联 比如一家公司(Company)和它所在的地址(Address).在业务逻辑中要求一家公司只有唯一的地址,一 ...
- mysql desc esc 基本命令总结
asc 按升序排列desc 按降序排列 下列语句部分是Mssql语句,不可以在access中使用. SQL分类:DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)DML—数据操 ...
- Sqlserver 查询 临时字段
临时字段格式 字段名=N'字段值' 例子如下: select cEmp_C, cEmp_N, oper_id=N'001', log_pw=N'123', sSex, cDept_C, cDept ...
- python学习笔记(time.time方法)
time.time()方法 返回的是 1970纪元后经过的浮点秒数 比较简单 总结如下: #!/usr/bin/env python # -*- coding: utf_8 -*- import ti ...
- Selenium with Python 005 - 调用js操作页面元素
WebDriver提供了execute_script()方法来执行JavaScript方法,格式如 driver.execute_script(script,*args) 执行js一般有两种场景,一是 ...
- Updated: Database Partitioning with EBS Whitepaper
Partitioning allows a single database table and its associated indexes to be broken into smaller com ...