https://vjudge.net/problem/POJ-3104 一开始思路不对,一直在想怎么贪心,或者套优先队列.. 其实是用二分法.感觉二分法求最值很常用啊,稍微有点思路的二分就是先推出公式: 对每件衣服:mid = x1(烘干时间)+x2(晾干时间):a[i] <= k*x1+x2:将1式带入2式得 x1>=(a[i]-mid)/(k-1)即每件衣服最少用时位x1向上取整. 注意这里k-1为分母,需要单独考虑k=1的情况 #include<iostream> #incl…
描述 http://poj.org/problem?id=2456 有n个小屋,线性排列在不同位置,m头牛,每头牛占据一个小屋,求最近的两头牛之间距离的最大值. Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10095   Accepted: 4997 Description Farmer John has built a new long barn, with N (2 <= N <=…
POJ3104 Drying 这个题由于题目数据比较大(1 ≤ ai ≤ 109),采用贪心的话肯定会超时,自然就会想到用二分. 设C(x)为true时表示所用时间为X时,可以把所有的衣服都烘干或者自然晾干, 此题自然就转化为了求把让所有衣服都干(烘干+晾干)所用的最小时间, 当c(X)为true时,ub=mid,尽量减小区间, 当C(x)为false时,表示时间为x时不成立,必须增加时间,令lb=mid+1 循环终止条件为lb=ub,此时任意输出一个值就ok了 此题有个坑:把衣服放入烘干机中时…
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…
Drying Time Limit: 2000MS Memory Limit: 65536K Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to make drying fas…
题目链接:http://poj.org/problem?id=3104 Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18378   Accepted: 4637 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afra…
题目链接:http://poj.org/problem?id=3258 题意:给n个石头,起点和终点也是两个石头,去掉这石头中的m个,使得石头间距的最小值最大. 思路:二分石头间的最短距离,每次贪心地check一下是否满足条件即可,具体看代码. AC代码: #include<iostream> #include<stack> #include<vector> #include<algorithm> #include<cmath> using na…
描述 http://poj.org/problem?id=3258 给出起点和终点之间的距离L,中间有n个石子,给出第i个石子与起点之间的距离d[i],现在要去掉m个石子(不包括起终点),求距离最近的两个石子(包括起终点)之间距离的最大值. River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10841   Accepted: 4654 Description Every year the co…
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace std; int main() { long long n; scanf("%I64d",&n); ,right=1e18,mid,num,m,s; ; while(left<=right) { mid=(left+right)>>; num = ; ;i &l…
https://vjudge.net/problem/POJ-3045 读题后提取到一点:例如对最底层的牛来说,它的崩溃风险=所有牛的重量-(底层牛的w+s),则w+s越大,越在底层. 注意范围lb=-INF. #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath> #includ…