P1528 Cutting Cakes
Description
Facer bought $n$ cakes today. Unfortunately, the lazy gluttons in the Information Group, including Qiuqiu, found out. He had no choice but to spare some to feed them. He promised to leave one bite for everyone and measured the size of each person's mouth. Facer has a knife and can cut cakes, but he cannot combine two cakes into one serving, and he will not give anyone two cakes. Now, how should Facer cut the cakes to satisfy the maximum number of people? (Facer's knife is perfect; cutting does not waste any cake.)
Input Format
The first line contains $n$, the number of cakes Facer has.
Each of the next $n$ lines contains the size of a cake.
The next line contains $m$, the number of people in the Information Group.
Each of the next $m$ lines contains one number, the size of a person's mouth.
Constraints: $1 \le n \le 50$, $1 \le m \le 1024$.
Output Format
One line: the maximum number of mouths Facer can fill.
Explanation/Hint
Translated by ChatGPT 5