poj 3258 River Hopscotch(二分+贪心)】的更多相关文章

题目:http://poj.org/problem?id=3258 题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都有唯一的距离 问现在要移除m块石头(S和E除外),每次移除的是与当前最短距离相关联的石头, 要求移除m块石头后,使得那时的最短距离尽可能大,输出那个最短距离. 和3273差不多... #include <iostream> #include <cstdio> #include <…
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21939 Accepted: 9081 Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The…
River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6697   Accepted: 2893 Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. T…
题目:http://poj.org/problem?id=3258 又A一道,睡觉去了.. #include <stdio.h> #include <algorithm> ]; int s, n, m; bool judge(int mid) { , cnt = ; ; i <= n+; i++) { sum += d[i] - d[i-]; if(sum < mid) cnt++; else sum = ; } if(cnt > m) ; ; } int mai…
/** 大意:给定n个点,删除其中的m个点,其中两点之间距离最小的最大值 思路: 二分最小值的最大值---〉t,若有距离小于t,则可以将前面的节点删除:若节点大于t,则继续往下查看 若删除的节点大于m,说明t,过于大,需要减小:若删除的节点小于m说明t过于小了,t需要增大 **/ #include <iostream> #include <algorithm> using namespace std; ]; int main() { long long l,n,m; cin>…
题目传送门 /* 二分:搜索距离,判断时距离小于d的石头拿掉 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; ll a[MAXN]; int n, m; bool check(ll d) { ; ; ; i&…
River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11031   Accepted: 4737 Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river.…
[题意] 牛要到河对岸,在与河岸垂直的一条线上,河中有N块石头,给定河岸宽度L,以及每一块石头离牛所在河岸的距离, 现在去掉M块石头,要求去掉M块石头后,剩下的石头之间以及石头与河岸的最小距离的最大值. [解法] 用二分做,但是开始写了三个版本的二分,全都wa. 无赖看了别人的二分,还是不理解,为什么他们写的就能过. 反复思索后,终于明白了:关键在于题目求的是什么. 做题思想:二分所求的最小距离的最大值mid,记录可以去掉的石头块数cnt(注意:当相邻的石头的距离小于等于mid,就可以去掉),…
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5193 Accepted: 2260 Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The e…
嗯... 题目链接:http://poj.org/problem?id=3258 一道很典型的二分答案的题目,和跳石头太像了!! 这道题的题目很显然,求最小中的最大值,注意这道题石头的位置不是从小到大输出的,所以要排序一遍... cnt记录可以跳过的石头个数:检查答案时,如果当前石头与前一个石头之间的距离小于mid,那么直接可以跳过,所以cnt++.如果跳不过去,则更新前一块石头的位置. 如果移走的石头数目小于等于m,说明跳的距离必须或者还可能更大,所以l = mid + 1:否则则要r = m…