【算法笔记4.4小节-贪心】问题 D: Repair the Wall

这是一篇关于算法笔记的文章,聚焦于如何使用贪心策略来解决一个问题:修复一个长为L英寸的矩形裂缝。用户Kitty有N个宽度为1英寸的矩形木块,每块木块的长度不同,目标是用最少数量的木块无间隙地填补裂缝。题目要求找出最小的木块数量以完成修复,如果无法修复则输出"impossible"。文章包含输入输出格式及样例,并提出通过排序木块长度并依次填充的方法来优化解决方案。
摘要由CSDN通过智能技术生成

题目链接:http://codeup.cn/problem.php?cid=100000584&pid=3

题目描述

 

Long time ago , Kitty lived in a small village. The air was fresh and the scenery was very beautiful. The only thing that troubled her is the typhoon.

When the typhoon came, everything is terrible. It kept blowing and raining for a long time. And what made the situation worse was that all of Kitty's walls were made of wood.

One day, Kitty found that there was a crack in the wall. The shape of the crack is 
a rectangle with the size of 1×L (in inch). Luckly Kitty got N blocks and a saw(锯子) from her neighbors.
The shape of the blocks were rectangle too, and the width of all blocks were 1 inch. So, with the help of saw, Kitty could cut down some of the blocks(of course she could use it directly without cutting) and put them in the crack, and the wall may be repa

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值