题目描述
Problem Description
Farmer John plans to build a fence around his pasture, so he needs some wooden planks of specific sizes. He goes to a lumber store to buy the wood. However, the store owner says that he only has a few large-sized planks left. But John can buy these planks and cut them into the sizes he needs. John has a magical saw that, when used to cut planks, does not result in any waste; for example, a plank of length 10 can be cut into two planks of lengths 8 and 2.
Your task is to determine the maximum number of planks of the sizes John needs that he can obtain, given the sizes of the planks the store owner can provide and the sizes of the planks John needs.
Input Format
The first line contains an integer $m (m \leq 50)$, indicating how many planks the store owner can provide to John. The next $m$ lines each contain the length of a plank provided by the store owner.
The next line (the $(m+2)$-th line) contains an integer $n (n \leq 1000)$, indicating how many planks John needs.
The next $n$ lines each contain the length of a plank that John needs. The lengths of the planks are less than 32767. (Each plank provided by the store owner and each plank needed by John can only be used once.)
Output Format
There is only one line, which contains the maximum number of planks that John can obtain that meet his specifications.
Sample Input and Output
Sample Input #1
4
30
40
50
25
10
15
16
17
18
19
20
21
25
24
30
Sample Output #1
7
Sample Input #2
3
20
10
10
9
3
3
3
5
5
7
8
8
9
Sample Output #2
7
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分