Drying (经典二分)

简要解决冬天衣物烘干问题,通过有效利用暖气片加快烘干速度。目标是最小化烘干所有衣物所需的时间。使用二分搜索算法,结合自然干燥和暖气加热两种方式,分析含水量变化,确定最佳烘干策略。
摘要由CSDN通过智能技术生成

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 faster. But the radiator is small, so it can hold only one thing at a time.

Jane wants to perform drying in the minimal possible time. She asked you to write a program that will calculate the minimal time for a given set of clothes.

There are n clothes Jane has just washed. Each of them took ai water during washing. Every minute the amount of water contained in each thing decreases by one (of course, only if the thing is not completely dry yet). When amount of water contained becomes zero the cloth becomes dry and is ready to be packed.

Every minute Jane can select one thing to dry on the radiator. The radiator is very hot, so the amount of water in this thing decreases by k this minute (but not less than zero — if the thing contains less than k water, the resulting amount of water will be zero).

The task is to minimize the total time of drying by means of using the radiator effectively. The drying process ends when all the clothes are dry.

翻译:冬天洗衣服很难,尤其是干衣服。但是简是个非常聪明的女孩。她不怕这个无聊的过程。简决定用暖气片来加快干燥速度。但是散热器很小,所以一次只能装一件东西。
简想在尽可能短的时间内进行烘干。她让你写一个程序来计算一套衣服的最短时间。
简刚洗了n件衣服。所有衣服每分钟都会在空气中干燥。每分钟每样东西所含的水量就会减少一次(当然,只有在东西还没有完全干燥的情况下)。当所含水量为零时,布料变干,准备包装。
简每分钟都能挑选一件东西放在暖气片上晾干。散热器是非常热的,所以这个东西里的水量在这一分钟减少了k(但不少于零——如果这个东西里的水少于k,那么产生的水量将是零)。
通过有效地使用散热器,使干燥总时间最小化。当所有的衣服都干了,干燥过程就结束了。

分析:首先我们要明白,二分什么,其实就是一种暴力的方法从数轴上取答案(每次得到的“答案”,我们就要分析是否符合题意)所以二分的难点都在于数学分析得出我们的符合题意的临界条件(最大或最小)

从题意分析,有两种干燥方式,自然干燥和加热干燥,在最短时间里分配使得时间最短,我们设有a件自然干燥,b件加热干燥,列出二元一次方程组

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值