report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
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 $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 ```
Additional Problems (Level 5)
GCD 2
Brewing potion 9
Amusement park
Growing mushrooms III
Queries on tree 3
Division problem
Watering II
Growing mushrooms II
Squid game
The last Ballade...
Sum of weights
Mushroom harvesting II
Flip
Pairs' value
Sorting queries
Microsoft Paint
Gene bank
Card games
Sequence
Topic
Complete Search
Binary search
Rating 1500
Solution (0) Solution