PROGRAMMING:Log cutting
A log with a length of N meters is given; In addition, there is a price list of segments, which gives the corresponding prices of L1, L2,... Li,... LK meters, P1, P2... PK (Li, PI are all positive integers), and seeks the maximum income that can be obtained from the segmented sale of cut logs.
For example, according to the price list given below,
| Li | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| -------- | -------- | -------- |
| Pi | 1 | 5 | 8 | 9 | 10 | 17 | 17 | 20 | 23 | 28 |
If we want to sell a 8-meter-long log, the optimal solution is to cut it into 2-meter and 6-meter sections, so we can get the maximum profit = L2 + L6 = 5 + 17 = 22. If you want to sell a 3-meter-long log, the best solution is not to cut it at all, but to sell it directly.
###Input format:
The first line inputs N and K, followed by the second line k Li (increasing order) and the third line corresponding K PI values.
(0###Output format:
The maximum cutting income of corresponding logs (the maximum income value in the title is guaranteed to be in the range of int).
###Input example:
Here is a set of inputs. For example:
```in
8 10
1 2 3 4 5 6 7 8 9 10
1 5 8 9 10 17 17 20 23 28
```
###Output example:
The corresponding output is given here. For example:
```out
twenty-two
```
answer:If there is no answer, please comment
Solution: use f (x, I) to represent the maximum value that can be produced by cutting logs with length of X meters into the range of L1 ~ Li.
Call f (n, K). There are
f(x,i) ={ 0 x<=0||i<=0
max{f(x-t*Li,i-1)+t*Pi} 0<=t<=x/Li
For example, according to the price list given below,
| Li | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| -------- | -------- | -------- |
| Pi | 1 | 5 | 8 | 9 | 10 | 17 | 17 | 20 | 23 | 28 |
If we want to sell a 8-meter-long log, the optimal solution is to cut it into 2-meter and 6-meter sections, so we can get the maximum profit = L2 + L6 = 5 + 17 = 22. If you want to sell a 3-meter-long log, the best solution is not to cut it at all, but to sell it directly.
###Input format:
The first line inputs N and K, followed by the second line k Li (increasing order) and the third line corresponding K PI values.
(0
The maximum cutting income of corresponding logs (the maximum income value in the title is guaranteed to be in the range of int).
###Input example:
Here is a set of inputs. For example:
```in
8 10
1 2 3 4 5 6 7 8 9 10
1 5 8 9 10 17 17 20 23 28
```
###Output example:
The corresponding output is given here. For example:
```out
twenty-two
```
answer:If there is no answer, please comment
Solution: use f (x, I) to represent the maximum value that can be produced by cutting logs with length of X meters into the range of L1 ~ Li.
Call f (n, K). There are
f(x,i) ={ 0 x<=0||i<=0
max{f(x-t*Li,i-1)+t*Pi} 0<=t<=x/Li