经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Repair the Wall

📝 题解 🔵 仅限 C++
题目描述
<p> <br /> </p> <div> 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. </div> <div> 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. </div> <div> One day, Kitty found that there was a crack in the wall. The shape of the crack is&nbsp;<br /> a rectangle with the size of 1×L (in inch). Luckly Kitty got N blocks and a saw(锯子) from her neighbors.<br /> 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 repaired perfectly, without any gap. </div> <div> Now, Kitty knew the size of each blocks, and wanted to use as fewer as possible of the blocks to repair the wall, could you help her ? </div> <p> <br /> </p> <p> <br /> </p>
输入格式
<p> <span style="font-family:Arial;">The problem contains many test cases, please process to the end of file( EOF ).<br /> Each test case contains two lines.<br /> In the first line, there are two integers L(0&lt;L&lt;1000000000) and N(0&lt;=N&lt;600) which<br /> mentioned above.<br /> In the second line, there are N positive integers. The ith integer Ai(0&lt;Ai&lt;1000000000 ) means that the ith block has the size of 1×Ai (in inch).</span> </p>
输出格式
<p> <span style="font-family:Arial;">For each test case , print an integer which represents the minimal number of blocks are needed.<br /> If Kitty could not repair the wall, just print "impossible" instead.</span> </p>
样例
样例输入 1
2 2 12 11 14 3 27 11 4 109 5 38 15 6 21 32 5 3 1 1 1
样例输出 1
1 1 5 impossible
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用