21160_TheBaleTower

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

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

Pro.ID

21160

Title

The Bale Tower

Title链接

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

AC

27

Submit

174

Ratio

15.52%

时间&空间限制

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

    Always bored with cud-chewing, the cows have invented a new game. One cow retrieves a set of N (3 ≤ N ≤ 20) hay bales from the shed each of which is one unit high. Each bale also has some unique width and unique breadth.

    A second cow tries to choose a set of bales to make the tallest stack of bales in which each bale can be placed only on a bale whose own width and breadth are smaller than the width and breadth of the bale below. Bales can not be rotated to interchange the width and breadth.

    Help the cows determine the highest achievable tower that can be legally built form a set of bales.

    输入

    Multiple test case. For each case:

    * Line 1: A single integer, N

    * Lines 2..N+1: Each line describes a bale with two space-separated integers, respectively the width and breadth

    输出

    Description

    Always bored with cud-chewing, the cows have invented a new game. One cow retrieves a set of N (3 ≤ N ≤ 20) hay bales from the shed each of which is one unit high. Each bale also has some unique width and unique breadth.

    A second cow tries to choose a set of bales to make the tallest stack of bales in which each bale can be placed only on a bale whose own width and breadth are smaller than the width and breadth of the bale below. Bales can not be rotated to interchange the width and breadth.

    Help the cows determine the highest achievable tower that can be legally built form a set of bales.

    Input

    Multiple test case. For each case:

    * Line 1: A single integer, N

    * Lines 2..N+1: Each line describes a bale with two space-separated integers, respectively the width and breadth

    Output

    For each case, output one line: The height of the tallest possible tower that can legally be built from the bales.

    Sample Input

    6
    6 9
    10 12
    9 11
    8 10
    7 8
    5 3

    Sample Output

    5

    Hint

    Input Details

    Six bales of various widths and breadths

    Output Details

    These bales can be stacked for a total height of 5:

    10 12
    9 11
    8 10
    6 9
    5 3

    [another stacking exists, too]

    Source

    样例输入

    6
    6 9
    10 12
    9 11
    8 10
    7 8
    5 3

    样例输出

    5

    提示

    Input Details

    Six bales of various widths and breadths

    Output Details

    These bales can be stacked for a total height of 5:

    10 12
    9 11
    8 10
    6 9
    5 3

    [another stacking exists, too]


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部