Problem1135--Repair the Wall

1135: Repair the Wall

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 32 MiB

Description



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 repaired perfectly, without any gap.
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 ?


题目描述:

很久以前,Kitty 住在一个小村庄里。那里空气清新,风景优美。唯一困扰她的事情就是台风。

台风来时,一切都会变得很糟糕。狂风暴雨会持续很长时间。更糟的是,Kitty 家的墙全都是木头做的。

有一天,Kitty 发现墙上裂开了一道缝。裂缝的形状是一个 1 × L(单位:英寸)的长方形。幸运的是,Kitty 从邻居那里得到了一把锯子和 N 块木板。

这些木板也都是长方形,并且它们的宽度全都是 1 英寸。因此,在锯子的帮助下,Kitty 可以把一些木板锯开(当然也可以直接使用整块木板而不锯),然后把它们填进裂缝中,这样墙就可以被完全修好,不会留下任何空隙。

现在,Kitty 已经知道每块木板的长度,希望用尽可能少的木板把墙修好。你能帮帮她吗?



题目描述:

很久以前,Kitty 住在一个小村庄里。那里空气清新,风景优美。唯一困扰她的事情就是台风。

台风来时,一切都会变得很糟糕。狂风暴雨会持续很长时间。更糟的是,Kitty 家的墙全都是木头做的。

有一天,Kitty 发现墙上裂开了一道缝。裂缝的形状是一个 1 × L(单位:英寸)的长方形。幸运的是,Kitty 从邻居那里得到了一把锯子和 N 块木板。

这些木板也都是长方形,并且它们的宽度全都是 1 英寸。因此,在锯子的帮助下,Kitty 可以把一些木板锯开(当然也可以直接使用整块木板而不锯),然后把它们填进裂缝中,这样墙就可以被完全修好,不会留下任何空隙。

现在,Kitty 已经知道每块木板的长度,希望用尽可能少的木板把墙修好。你能帮帮她吗?





Input

The problem contains many test cases, please process to the end of file( EOF ).
Each test case contains two lines.
In the first line, there are two integers L(0<L<1000000000) and N(0<=N<600) which
mentioned above.
In the second line, there are N positive integers. The ith integer Ai(0<Ai<1000000000 ) means that the ith block has the size of 1×Ai (in inch).



本题包含多组测试数据,请处理到文件结束(EOF)。

每组测试数据包含两行:

第一行包含两个整数 L 和 N:

L (0 < L < 1000000000) 表示裂缝的长度
N (0 <= N < 600) 表示木板的数量
第二行包含 N 个正整数,第 i 个整数 Ai (0 < Ai < 1000000000) 表示第 i 块木板的尺寸为 1 × Ai(单位:英寸)。




Output

For each test case , print an integer which represents the minimal number of blocks are needed.
If Kitty could not repair the wall, just print "impossible" instead.



输出:

对于每组测试数据,输出一个整数,表示修好墙所需的最少木板数。

如果 Kitty 无法修好墙,则输出:impossible






Sample Input Copy

2 2
12 11 
14 3
27 11 4 
109 5
38 15 6 21 32 
5 3
1 1 1

Sample Output Copy

1
1
5
impossible

Source/Category