回 帖 发 新 帖 刷新版面

主题:[讨论]pascal求解

吃糖果
【题目描述】

    小头是个聪明的孩子,同时他也很馋嘴。鉴于上次单元考小头拿了全班第一,妈妈买来一堆糖果奖励小头,并且对小头说:“妈妈知道你很喜欢吃糖果,但是今天的糖果是特殊的,每一颗糖果都需要花一个特定的时间段来吃,并且在这段时间里你不能吃其他糖果。所以到底能吃多少颗糖果就看你的本事了。”
    妈妈一共买了n颗糖果,用1、2、3……n编号,对于第i颗糖果有Li和Ri,表示小头需要用[Li,Ri]这段时间来吃掉第i颗糖果。显然如果小头要同时吃掉第i颗和第j,那么必须满足(Ri<Lj)或者(Li>Rj)。
贪吃的小头自然想吃掉尽量多的糖果,但是在美味的糖果面前,小头的智商瞬间降为负值,连1+1都变成了绝世难题。于是好心的你决定发挥雷锋精神,告诉小头他最多能吃多少颗。假设时间无限。

【输入格式】

    第一行一个正整数n,表示有n颗糖果
    接下来n行每行两个正整数,Li、Ri 表示第i颗糖果的时间段

【输出格式】

    仅包含一个数,即小头最多能吃多少颗糖果

【样例输入】

    5
    2 4
    1 7
    10 11
    4 5
    5 8

【样例输出】
    3

【样例解释】

    选择第(1,3,5)颗糖果,他们时间段分别为[2,4]、[5,8]、[10,11]互不干扰。

【数据规模】

    40%的数据,n≤10,1≤Li≤Ri≤100
80%的数据,n≤1000,1≤Li≤Ri≤10000
100%的数据,n≤100000,1≤Li≤Ri≤1000000000

回复列表 (共2个回复)

沙发




Practicality [url=http://www.mmopowerlevel.net]wow power leveling[/url] is also very important when choosing a gadget [url=http://www.mogxe.com/PowerLevel.php?gid=1]wow power leveling[/url] to give. You don’t want to spend a lot of money on [url=http://www.mmopowerlevel.net/buy.php]wow gold uk[/url] something only to find out that it is useless. Better to give something that the [url=http://www.mmopowerlevel.net/powerlist.php?fid=688]wow power leveling[/url] other person can use. You may not know it but you actually need a stun gun. In our world today where you are unsure of your safety, you need a stun gun to protect yourself. Why don’t you [url=http://www.mogxe.com]wow power leveling[/url] give it as a gift too? There is new stun master stun guns that you can buy as a gift. This stun gun is the best and it [url=http://www.mogxe.com/PowerLevel.php?gid=21]aion power level[/url] can protect the person you are giving this gift to.
Giving gadgets as gifts during the holidays is great. These [url=http://www.mogxe.com/PowerLevel.php?gid=21]aion powerleveling[/url] gadgets are useful and people like having them. If [url=http://www.mogxe.com/BuyGold.php?gid=1]buy wow gold[/url] you want to impress someone this is the best kind of gift that you can give to. No matter [url=http://www.mogxe.com/BuyGold.php?gid=21]aion kinah[/url] if that person is a girl or boy or whatever the age is, they would surely appreciate [url=http://www.mmopowerlevel.net/powerlist.php?fid=7422]aion power level[/url] having these electronic items as presents.

板凳

类似“滑窗”。。
再麻烦的用网络流

我来回复

您尚未登录,请登录后再回复。点此登录或注册