一个不错的二分,注释在代码里 #include <stdio.h> #include <cstring> #include <algorithm> #include <cmath> #include <iostream> using namespace std; ///二分搜索答案,最大化最小值 int main() { int L,n,m; ]; while(~scanf("%d %d %d",&L,&n,&…
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 excitement takes place on a long, straight river with a rock at the start and another rock at th…
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formula Ai+Bj+Ck = X.    Input There are many cases. Every data case is de…
River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9923   Accepted: 4252 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…
C. Tavas and Karafs #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <vector> #include <set> #include <map> #include <stack&g…
题目真是不好读,大意例如以下(知道题意就非常好解了) 大致题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都有唯一的距离 问如今要移除m块石头(S和E除外),每次移除的是与当前最短距离相关联的石头,要求移除m块石头后,使得那时的最短距离尽可能大,输出那个最短距离. //Memory Time //420K 391MS #include<iostream> #include<algorithm> usi…
River Hopscotch 直接中文 Descriptions 每年奶牛们都要举办各种特殊版本的跳房子比赛,包括在河里从一块岩石跳到另一块岩石.这项激动人心的活动在一条长长的笔直河道中进行,在起点和距离起点 L 远的终点各有一块岩石 (1 ≤ L ≤ 10^9).在起点和终点之间,有 N 块岩石 (0 ≤ N ≤ 50000),每块岩石与起点的距离分别为 Di (0 < Di < L). 在比赛过程中,奶牛轮流从起点出发,尝试到达终点,每一步只能从一块岩石跳到另一块岩石.当然,实力不济的奶…
脑子一抽写了个堆,发现不对才想起来最值用二分 然后判断的时候贪心的把不合mid的区间打通,看打通次数是否小于等于m即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=50005; int L,n,m,a[N]; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<…
https://vjudge.net/problem/POJ-3258 二分最小值,判断需要删去的点的个数,如果大于给定,则直接return 0,则说明该数需要再小. 最后注意,起点是0终点是l,起点可以不加进数组,终点必须加进去!! #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath…
题目链接:http://poj.org/problem?id=3258 题意:给n个石头,起点和终点也是两个石头,去掉这石头中的m个,使得石头间距的最小值最大. 思路:二分石头间的最短距离,每次贪心地check一下是否满足条件即可,具体看代码. AC代码: #include<iostream> #include<stack> #include<vector> #include<algorithm> #include<cmath> using na…