#1189. 【算法1-6】木材加工

【算法1-6】木材加工

说明

木材厂有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 根原木,现在想把这些木头切割成 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>k 段长度为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>l 的小段木头(木头有可能有剩余)。

当然,我们希望得到的小段木头越长越好,请求出 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>l 的最大值。

木头长度的单位是 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>cm</mtext></mrow></semantics></math>cm,原木的长度都是正整数,我们要求切割得到的小段木头的长度也是正整数。

例如有两根原木长度分别为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>11</mn></mrow></semantics></math>11 和 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>21</mn></mrow></semantics></math>21,要求切割成等长的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>6</mn></mrow></semantics></math>6 段,很明显能切割出来的小段木头长度最长为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>5</mn></mrow></semantics></math>5

输入格式

第一行是两个正整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo separator="true">,</mo><mi>�</mi></mrow></semantics></math>n,k,分别表示原木的数量,需要得到的小段的数量。

接下来 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 行,每行一个正整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>Li,表示一根原木的长度

输出格式

仅一行,即 l 的最大值。

如果连 1cm1cm 长的小段都切不出来,输出 0

样例

3 7
232
124
456
114

提示

数据范围:

对于 

<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>100</mn><mi mathvariant="normal">%</mi></mrow></semantics></math>100% 的数据,有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>5</mn></msup></mrow></semantics></math>1n105<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>8</mn></msup></mrow></semantics></math>1k108<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>�</mi><mi>�</mi></msub><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>8</mn></msup><mo stretchy="false">(</mo><mi>�</mi><mo>∈</mo><mo stretchy="false">[</mo><mn>1</mn><mo separator="true">,</mo><mi>�</mi><mo stretchy="false">]</mo><mo stretchy="false">)</mo></mrow></semantics></math>1Li108(i[1,n])