22136_BrotherLiao'sGame

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

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

Pro.ID

22136

Title

Brother Liao's Game

Title链接

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

AC

5

Submit

36

Ratio

13.89%

时间&空间限制

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

    Zhangliao is a smart boy with long hair, and everybody calls him Brother Liao. Brother Liao likes playing a funny computer game. When the game begins, there are n blockhouses. Each blockhouse has a defensive value and a bonus value. The player has a initial attack value. He will get one score on destroying one blockhouse. Every time, Brother Liao chooses a blockhouse as a target to attack. As all the undestroyed blockhouses will work together to resist, to destroy the target blockhouse, the player's attack value must be larger than or equal to the sum of defensive value of all the undestroyed blockhouses, otherwise Brother Liao will lose the game. If the player succeeds to destroy the target blockhouse, his attack value will EQUAL to the bonus value of the target blockhouse, and then Brother Liao will choose the next target.

    As Brother Liao is good at programming, he has modified the game. Before the game starts, he can eliminate any blockhouses as he likes using bombs, but he will not get scores through this way. How many scores can Brother Liao get at most?

    输入

    There are several test cases in the input.

    Each test case start with a line containing a positive integer N ( N ≤ 1000 ), which is the number of blockhouses;

    N lines followed;

    The i-th line contains two nonnegativc integers, which are the defensive value and bonus of the i-th blockhouse respectively. They would not exceed 2000000.

    The last line contains an integer which is the player's initial attack value.

    The input terminates with EOF.

    输出

    Description

    Zhangliao is a smart boy with long hair, and everybody calls him Brother Liao. Brother Liao likes playing a funny computer game. When the game begins, there are n blockhouses. Each blockhouse has a defensive value and a bonus value. The player has a initial attack value. He will get one score on destroying one blockhouse. Every time, Brother Liao chooses a blockhouse as a target to attack. As all the undestroyed blockhouses will work together to resist, to destroy the target blockhouse, the player's attack value must be larger than or equal to the sum of defensive value of all the undestroyed blockhouses, otherwise Brother Liao will lose the game. If the player succeeds to destroy the target blockhouse, his attack value will EQUAL to the bonus value of the target blockhouse, and then Brother Liao will choose the next target.

    As Brother Liao is good at programming, he has modified the game. Before the game starts, he can eliminate any blockhouses as he likes using bombs, but he will not get scores through this way. How many scores can Brother Liao get at most?

    Input

    There are several test cases in the input.

    Each test case start with a line containing a positive integer N ( N ≤ 1000 ), which is the number of blockhouses;

    N lines followed;

    The i-th line contains two nonnegativc integers, which are the defensive value and bonus of the i-th blockhouse respectively. They would not exceed 2000000.

    The last line contains an integer which is the player's initial attack value.

    The input terminates with EOF.

    Output

    For each test case, output the scores that Brother Liao can get at most.

    Sample Input

    3
    10 9
    25 30
    8 7
    50
    5
    100 230
    334 331
    33 288
    35 100
    334 22
    600

    Sample Output

    3
    4

    Source

    样例输入

    3
    10 9
    25 30
    8 7
    50
    5
    100 230
    334 331
    33 288
    35 100
    334 22
    600

    样例输出

    3
    4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部