22663_Droppingthestones

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

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

Pro.ID

22663

Title

Dropping the stones

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    You have N stones (1 ≤ N ≤ 10) , each stone is characterized by weight pi and cost vi ( i=1, …, N ) . You should drop these stones by a gutter into one of the two bunkers: A or В.

    The mechanism of receiving bunkers switching works as follows. The stones are dropping into one of the bunkers until the weight of this bunker's content will exceed the weight of stones in other bunker by at least D. Then the gutter switches to the other bunker. At the beginning both bunkers are empty, and the first stone falls into the bunker А.

    The task is to collect stones with maximum total cost in bunker B after all stones have been dropped.

    输入

    The input consists of N+1 lines.

    The first line contains values N and D separated by one or several spaces. The next lines contain values pi and vi, also separated by spaces. All input data (except N) are integers from 0 to 10000.

    输出

    Description

    You have N stones (1 ≤ N ≤ 10) , each stone is characterized by weight pi and cost vi ( i=1, …, N ) . You should drop these stones by a gutter into one of the two bunkers: A or В.

    The mechanism of receiving bunkers switching works as follows. The stones are dropping into one of the bunkers until the weight of this bunker's content will exceed the weight of stones in other bunker by at least D. Then the gutter switches to the other bunker. At the beginning both bunkers are empty, and the first stone falls into the bunker А.

    The task is to collect stones with maximum total cost in bunker B after all stones have been dropped.

    Input

    The input consists of N+1 lines.

    The first line contains values N and D separated by one or several spaces. The next lines contain values pi and vi, also separated by spaces. All input data (except N) are integers from 0 to 10000.

    Output

    Output a single line with total cost of stones in the bunker В.

    Sample Input

    4 2
    2 2
    2 2
    1 1
    1 1

    Sample Output

    3

    Source

    样例输入

    4 2
    2 2
    2 2
    1 1
    1 1

    样例输出

    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部