21107_Phidias

2022-5-16 18:18| 发布者: Hocassian| 查看: 46| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504847050400-Problem List-采集的数据-后羿采集器.html

Pro.ID

21107

Title

Phidias

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21107

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1500/500 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Famous ancient Greek sculptor Phidias is making preparations to build another marvelous monument. For this purpose he needs rectangular marble plates of sizes W1 H1, W2 H2, ..., WN HN.

    Recently, Phidias has received a large rectangular marble slab. He wants to cut the slab to obtain plates of the desired sizes. Any piece of marble (the slab or the plates cut from it) can be cut either horizontally or vertically into two rectangular plates with integral widths and heights, cutting completely through that piece. This is the only way to cut pieces and pieces cannot be joined together. Since the marble has a pattern on it, the plates cannot be rotated: if Phidias cuts a plate of size A B then it cannot be used as a plate of size B A unless A B. He can make zero or more plates of each desired size. A marble plate is wasted if it is not of any of the desired sizes after all cuts are completed. Phidias wonders how to cut the initial slab so that as little of it as possible will be wasted.

    As an example, assume that in the figure below the width of the original slab is 21 and the height of the original slab is 11, and the desired plate sizes are 10 4, 6 2, 7 5, and 15 10. The minimum possible area wasted is 10, and the figure shows one sequence of cuts with total waste area of size 10.


    Your task is to write a program that, given the size of the original slab and the desired plate sizes, calculates the minimum total area of the original slab that must be wasted.

    输入

    The first line of input contains two integers: first W, the width of the original slab, and then H, the height of the original slab. The second line contains one integer N: the number of desired plate sizes. The following N lines contain the desired plate sizes. Each of these lines contains two integers: first the width Wi and then the height Hi of that desired plate size (1 ≤ i ≤ N).

    0≤Q≤150000, 0≤M≤2000, 0≤K≤2000, 3≤ N1≤150, 3≤N2≤150, ..., 3≤NM≤150, 2≤ R1≤150, 2≤R2≤150,..., 2≤RK ≤150. The total number of cypress trees in the fields and strips is at least Q.

    输出

    Description

    Famous ancient Greek sculptor Phidias is making preparations to build another marvelous monument. For this purpose he needs rectangular marble plates of sizes W1 H1, W2 H2, ..., WN HN.

    Recently, Phidias has received a large rectangular marble slab. He wants to cut the slab to obtain plates of the desired sizes. Any piece of marble (the slab or the plates cut from it) can be cut either horizontally or vertically into two rectangular plates with integral widths and heights, cutting completely through that piece. This is the only way to cut pieces and pieces cannot be joined together. Since the marble has a pattern on it, the plates cannot be rotated: if Phidias cuts a plate of size A B then it cannot be used as a plate of size B A unless A B. He can make zero or more plates of each desired size. A marble plate is wasted if it is not of any of the desired sizes after all cuts are completed. Phidias wonders how to cut the initial slab so that as little of it as possible will be wasted.

    As an example, assume that in the figure below the width of the original slab is 21 and the height of the original slab is 11, and the desired plate sizes are 10 4, 6 2, 7 5, and 15 10. The minimum possible area wasted is 10, and the figure shows one sequence of cuts with total waste area of size 10.


    Your task is to write a program that, given the size of the original slab and the desired plate sizes, calculates the minimum total area of the original slab that must be wasted.
    Input

    The first line of input contains two integers: first W, the width of the original slab, and then H, the height of the original slab. The second line contains one integer N: the number of desired plate sizes. The following N lines contain the desired plate sizes. Each of these lines contains two integers: first the width Wi and then the height Hi of that desired plate size (1 ≤ i ≤ N).

    0≤Q≤150000, 0≤M≤2000, 0≤K≤2000, 3≤ N1≤150, 3≤N2≤150, ..., 3≤NM≤150, 2≤ R1≤150, 2≤R2≤150,..., 2≤RK ≤150. The total number of cypress trees in the fields and strips is at least Q.

    Output
    The output is to contain one line with a single integer: the minimum total area of the original slab that must be wasted.
    Sample Input
    5
    21 11
    4
    10 4
    6 2
    7 5
    15 10
    Sample Output
    10
    Source

    样例输入

    5
    21 11
    4
    10 4
    6 2
    7 5
    15 10

    样例输出

    10

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部