[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>一、题目描述
某公司员工食堂以盒饭的方式供餐。
为将员工取餐排队时间降为0,食堂的供餐速度必须要足够快。
现在需要根据以往员工取餐的统计信息,计算出一个刚好能达到排队时间为0的最低供餐速度。
即,食堂在每个单位时间内必须至少做出多少份盒饭才能满足要求。
<>二、输入描述
第一行输入一个正整数N,表示食堂开餐时长。
第二行为一个正整数M,表示开餐前食堂已经准备好的盒饭数量;
第三行为N个正整数,用空格分割,依次表示开餐时间内按时间顺序每个单位时间进入食堂取餐的人数。
<>三、输出描述
一个整数,能满足题目要求的最低供餐速度。(每个单位时间需要做出多少份盒饭)。
<>四、补充说明
每人只能取一份盒饭。
需要满足排队时间为0,必须保证取餐员工到达食堂时,食堂库存盒饭数量不少于本次来取餐的人数。
第一个单位时间来取餐的员工只能取开餐前食堂准备好的盒饭。
每个单位时间里制作的盒饭只能供给后续单位时间来的取餐员工。食堂在每个单位时间里制作的盒饭数量是相同的。
<>五、解题思路
* 采用二分法;
* left为最小出餐速度,right为最大出餐速度 = 总人数 - 已经准备好的盒饭数量;
* 判断是否还剩余盒饭;
* 如果盒饭不够了,返回false;
* 如果盒饭足够,则剩余盒饭数量 = 目前盒饭数量 - 每个时间段的取餐人数,再加上当前时间段生产的盒饭数量;