Brewing potion - MarisaOJ: Marisa Online Judge

Brewing potion

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has $m$ potion bottles, and the $i^{th}$ bottle requires an exact amount of mushrooms, $s_i$. She also has $n$ mushrooms. Each mushroom can be split into several smaller pieces if needed. For example, a mushroom of size $a_i$ can be split into $k$ pieces such that $a_i = b_1 + b_2 + ... + b_k$. 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 $a_i$, representing the sizes of the mushrooms. - The third line contains $m$ integers $s_i$, 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 \le n \le 30$. - $1 \le m \le 60$. - $1 \le a_i, s_i \le 100$. ### Example Input: ``` 4 10 30 40 50 25 15 16 17 18 19 20 21 25 24 30 ``` Output: ``` 7 ```