P2329 [SCOI2005] Fence
Background
本题**不保证**存在**可以通过满足本题数据范围的任意数据**做法。可以通过此题的程序不一定完全正确(算法时间复杂度错误、或不保证正确性)
本题为搜索题,本题不接受 hack 数据。[关于此类题目的详细内容](https://www.luogu.com.cn/paste/pf94n89x)
Description
Farmer John plans to build a fence to enclose his pasture, so he needs boards of certain lengths. He goes to a lumber store, but the owner has only a small number of large boards left. John may buy these boards and cut them into the lengths he needs. John has a magic saw that produces no waste; for example, a board of length $10$ can be cut into boards of length $8$ and $2$.
Your task: Given the lengths of the boards John needs and the lengths of the boards available at the store, compute the maximum number of required boards John can obtain.
Input Format
- The first line contains an integer $m$ ($m \leq 50$), the number of boards the store owner can provide. The next $m$ lines each contain the length of one available board.
- The next line contains an integer $n$ ($n \leq 1000$), the number of boards John needs.
- The next $n$ lines each contain the length of one required board. Each length is less than $32767$. Each available board can be used at most once, and each required board can be fulfilled at most once.
Output Format
Output a single line with the maximum number of boards that meet John's requirements.
Explanation/Hint
Translated by ChatGPT 5