bzoj1650 / P2855 [USACO06DEC]河跳房子River Hopscotch / P2678 (noip2015)跳石头
P2855 [USACO06DEC]河跳房子River Hopscotch
二分+贪心
每次二分最小长度,蓝后检查需要去掉的石子数是否超过限制。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 50010
int n,m,L,a[N];
bool check(int lim){
int k=;
for(int i=,j=;i<=n;++i){
if(a[i]-a[j]<lim) ++k;
else j=i;
}return k<=m;
}
int main(){
scanf("%d%d%d",&L,&n,&m); a[++n]=L;
for(int i=;i<n;++i) scanf("%d",&a[i]);
sort(a+,a+n+);
int l=,r=L;
while(l<r){
int mid=l+((r-l)>>);
if(check(mid)) l=mid+;
else r=mid;
}printf("%d",check(l)?l:l-);
return ;
}
bzoj1650 / P2855 [USACO06DEC]河跳房子River Hopscotch / P2678 (noip2015)跳石头的更多相关文章
- POJ 3258 River Hopscotch(二分答案)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21939 Accepted: 9081 Desc ...
- 【POJ - 3258】River Hopscotch(二分)
River Hopscotch 直接中文 Descriptions 每年奶牛们都要举办各种特殊版本的跳房子比赛,包括在河里从一块岩石跳到另一块岩石.这项激动人心的活动在一条长长的笔直河道中进行,在起点 ...
- River Hopscotch(二分POJ3258)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9263 Accepted: 3994 Descr ...
- River Hopscotch(二分最大化最小值)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9923 Accepted: 4252 D ...
- POJ 3258 River Hopscotch
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11031 Accepted: 4737 ...
- POJ 3258 River Hopscotch (binarysearch)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5193 Accepted: 2260 Descr ...
- POJ3285 River Hopscotch(最大化最小值之二分查找)
POJ3285 River Hopscotch 此题是大白P142页(即POJ2456)的一个变形题,典型的最大化最小值问题. C(x)表示要求的最小距离为X时,此时需要删除的石子.二分枚举X,直到找 ...
- POJ--3258 River Hopscotch (最小值最大化C++)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15273 Accepted: 6465 ...
- River Hopscotch
River Hopscotch http://poj.org/problem?id=3258 Time Limit: 2000MS Memory Limit: 65536K Total Submi ...
随机推荐
- poj1182 食物链【并查集-好题!】
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用两 ...
- Python:字符串处理函数
split() / join() 拆分和组合 #split() 通过指定分隔符对字符串进行切片(拆分),默认空格符 lan = "python ruby c c++ swift" ...
- eclipse反编译插件jadClipse安装使用教程
previously:最近在学习Dependency Injection(依赖注入)模式,看了 martin fowler 的 文章(原文:https://martinfowler.com/artic ...
- postgresql+postgis+pgrouting安装步骤图解
1.在此(https://www.bigsql.org/postgresql/installers.jsp/)下载postgresql(开源数据库,gis行业推荐使用); 2.在此(http://wi ...
- linux下的vdso与vsyscall
传统的系统调用是怎样的? —— int 0x80的时代 .... :通过寄存器传参 mov $n ,eax :将系统调用号放到eax中 int 0x80 sysenter/sysexit的出 ...
- oracle(四) 常用语句
1.分页 select t2.* from (select rownum row, t1.* from your_table where rownum < ?) t2 where t2.row ...
- javaScript高级教程(四) 复制对象
//返回新对象,双方互不影响 function clone(obj){ //alert('clone'); if(typeof(obj) != 'object') return obj; if(obj ...
- 007-jdk1.6版本新特性
一.JDK1.6 名称:Mustang(野马) 发布日期:2006-04 新特性: 1.1.AWT新增加了两个类:Desktop和SystemTray[忽略] 前者可以用来打开系统默认浏览器浏览指定的 ...
- 十天精通CSS3(9)
Keyframes介绍 Keyframes被称为关键帧,其类似于Flash中的关键帧.在CSS3中其主要以“@keyframes”开头,后面紧跟着是动画名称加上一对花括号“{…}”,括号中就是一些不同 ...
- 实习培训——Servlet(5)
实习培训——Servlet(5) 1 Servlet 简介 Servlet 是什么? Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HT ...