luogu#P2329. [SCOI2005] 栅栏【疑似错题】

    ID: 1327 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>搜索2005四川各省省选深度优先搜索 DFS剪枝

[SCOI2005] 栅栏【疑似错题】

Background

This problem does not guarantee the existence of any solution that can pass all test data within the given constraints. Programs that pass this problem may not be entirely correct (either in terms of time complexity or correctness). All published solutions for this problem can be defeated by constructed test cases and are for learning reference only.

Detailed information about this type of problem.

Problem 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 1010 can be cut into boards of length 88 and 22.

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 mm (m50m \leq 50), the number of boards the store owner can provide. The next mm lines each contain the length of one available board.
  • The next line contains an integer nn (n1000n \leq 1000), the number of boards John needs.
  • The next nn lines each contain the length of one required board. Each length is less than 3276732767. 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.

4
30
40
50
25
10
15
16
17
18
19
20
21
25
24
30

7
3
20
10
10
9
3
3
3
5
5
7
8
8
9

7

Hint

Translated by ChatGPT 5