difask's blog

By difask, history, 9 years ago, translation, In English

Hello everyone!

Please, help me to solve this problem. I've thought about it with my friends for a long time, but we couldn't find the solution.

You're given N<50 planks with known lengths a[i]<10000. You can cut them in any amount of planks you want. Also you're given planks that you should get. Their amount M<1024, length b[i]<128. You should find maximal number of planks that you can get.

Example:
Input:
4
30 40 50 25
10
15 16 17 18 19 20 21 25 24 30
Output:
7
Explanation:
15 + 16 + 17 -> 50 (cutting 50 into 15, 16, 17, 50-15-16-17=2)
18 + 19 -> 40
20 -> 30
21 -> 25

Thanks!

P.S. I'm currently preparing for my English exam and want to improve my writing. If you notice any mistakes, please send a message or write in the comments section. Thanks!

  • Vote: I like it
  • +30
  • Vote: I do not like it