Processing math: 100%
Brewing potion 9 - MarisaOJ: Marisa Online Judge

Brewing potion 9

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has m potion bottles, and the ith bottle requires an exact amount of mushrooms, si. She also has n mushrooms. Each mushroom can be split into several smaller pieces if needed. For example, a mushroom of size ai can be split into k pieces such that ai=b1+b2+...+bk. A potion bottle cannot contain more than one piece of a mushroom. This means each potion bottle can only hold either a whole mushroom or a single piece split from a mushroom. Determine the maximum number of potion bottles Marisa can fill. ### Input - The first line contains two integer n,m. - The second line contains n integers ai, representing the sizes of the mushrooms. - The third line contains m integers si, representing the required sizes for the potion bottles. ### Output - Output a single integer representing the maximum number of potion bottles Marisa can fill. ### Constraints - 1≤n≤30. - 1≤m≤60. - 1≤ai,si≤100. ### Example Input: 4103040502515161718192021252430 Output: 7