22841_HungryCows

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

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

Pro.ID

22841

Title

Hungry Cows

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    he cows are lined up at their feed trough, which has individualized feeding buckets numbered sequentially from 1 through N (1 ≤ N ≤ 2000). Each night a lucky cow gets to eat from a number of buckets according to Farmer John's rules.

    Farmer John posts a list of no more than B bucket-sequences (a bucket sequence is a pair of integers (a pair like start-end where 1 ≤ startendN and the sequence includes buckets start through end, e.g., 1-3, 7-8, 3-4). FJ's rules allow the cow to choose as many of the intervals as she wishes, as long as no bucket is mentioned more than once in the total set of chosen intervals.

    Of course, cows are like anyone else and want as much feed as they can get. Given a set of bucket-sequences, help the lucky cow find the best sequence which yields the greatest amount of feed.

    In the example above, bucket-sequences 1-3 and 3-4 overlap; the wise cow chooses the set of {1-3, 7-8} for a lavish dinner of five buckets.

    输入

    * Line 1: One integer B (1 ≤ B ≤ 1000)

    * Lines 2..B+1: Each line contains a two integer bucket sequence with the smaller bucket number first

    输出

    Description

    he cows are lined up at their feed trough, which has individualized feeding buckets numbered sequentially from 1 through N (1 ≤ N ≤ 2000). Each night a lucky cow gets to eat from a number of buckets according to Farmer John's rules.

    Farmer John posts a list of no more than B bucket-sequences (a bucket sequence is a pair of integers (a pair like start-end where 1 ≤ startendN and the sequence includes buckets start through end, e.g., 1-3, 7-8, 3-4). FJ's rules allow the cow to choose as many of the intervals as she wishes, as long as no bucket is mentioned more than once in the total set of chosen intervals.

    Of course, cows are like anyone else and want as much feed as they can get. Given a set of bucket-sequences, help the lucky cow find the best sequence which yields the greatest amount of feed.

    In the example above, bucket-sequences 1-3 and 3-4 overlap; the wise cow chooses the set of {1-3, 7-8} for a lavish dinner of five buckets.

    Input

    * Line 1: One integer B (1 ≤ B ≤ 1000)

    * Lines 2..B+1: Each line contains a two integer bucket sequence with the smaller bucket number first

    Output

    A single line with a single integer that is the greatest number of feed buckets the lucky cow can eat.

    Sample Input

    3
    1 3
    7 8
    3 4

    Sample Output

    5

    Source

    样例输入

    3
    1 3
    7 8
    3 4

    样例输出

    5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部