POJ3104 Drying —— 二分】的更多相关文章

POJ3104 Drying 这个题由于题目数据比较大(1 ≤ ai ≤ 109),采用贪心的话肯定会超时,自然就会想到用二分. 设C(x)为true时表示所用时间为X时,可以把所有的衣服都烘干或者自然晾干, 此题自然就转化为了求把让所有衣服都干(烘干+晾干)所用的最小时间, 当c(X)为true时,ub=mid,尽量减小区间, 当C(x)为false时,表示时间为x时不成立,必须增加时间,令lb=mid+1 循环终止条件为lb=ub,此时任意输出一个值就ok了 此题有个坑:把衣服放入烘干机中时…
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…
题目大意:有n件湿的衣服,每件衣服都有相应的湿度,每分钟每件衣服的湿度减1(除了在烘干机里的衣服),现在有一个烘干机,烘干机一分钟可以让一件衣服的湿度降低k,问至少要花多少分钟才能使每件衣服的湿度为0 解题思路:贪心的话,每分钟都要使用到烘干机.  枚举时间,如果湿度小于等于时间的话,就不用考虑了,在枚举时间内肯定会干的  如果湿度大于枚举时间的话,就要考虑一下了,该衣服要在给定时间内湿度变为零的话就要满足该式子,设已经过了cnt分钟了,当前这件衣服的湿度为num[i],枚举的时间为mid,那么…
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…
Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7916   Accepted: 2006 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 d…
题目链接:http://poj.org/problem?id=3104                                                                                                      Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11128   Accepted: 2865 Description It is very…
Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15604   Accepted: 3976 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…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13703   Accepted: 3527 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…
传送门 表示又是神题一道 Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9327   Accepted: 2364 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 proces…