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 ...
随机推荐
- HDFS文件上传
下图描述了Client向HDFS上传一个200M大小的日志文件的大致过程: 1)首先,Client发起文件上传请求,即通过RPC与NameNode建立通讯. 2)NameNode与各DataNode使 ...
- ssh各种姿势---ssh-keygen 生成ssh公钥和私钥
利用ssh-keygen -t rsa可以生成ssh公钥和私钥,实现免输密码的ssh登陆 ssh-keygen -l -f /etc/ssh_host_rsa_key ssh-keygen ...
- SUSE12的虚拟机安装以及ORACLE12C的安装
在本文中用到的所有参数,均位于文后附录中 在VMware中新建虚拟机,建好之后挂载光盘,启动虚拟机进入安装界面 初始化中 选择跳过注册 选择DVD模式 选择接受许可证条款 默认选择 选择默认系统 选择 ...
- MySQL check table/optimize table/analyze table/REPAIR TABLE
MySQL check table/optimize table/analyze table/REPAIR TABLE 转自:https://www.cnblogs.com/datastack/p/3 ...
- python float()
1.函数功能将一个数值或者字符转换成浮点型数值 >>> a = 12345 >>> amount = float(a) >>> print(amo ...
- Linux环境下解压rar文件
可以用unrar命令解压rar后缀的文件 unrar e test.rar 解压文件到当前目录 unrar x test.rar /path/to/extract unrar l test.rar 查 ...
- [LeetCode] 257. Binary Tree Paths_ Easy tag: DFS
Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example ...
- [LeetCode] 102. Binary Tree Level Order Traversal_Medium tag: BFS
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...
- [LeetCode] 203. Remove Linked List Elements_Easy tag: Linked LIst
Remove all elements from a linked list of integers that have value val. Example: Input: 1->2-> ...
- Log Parser 2.2 + Log Parser Lizard GUI 分析IIS日志示例
Log Parser 日志分析工具,用命令行操作,可以分析 IIS logs,event logs,active directory,log4net,file system,t-sql Log Par ...