21949_Rollercoasterfun

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

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

Pro.ID

21949

Title

Roller coaster fun

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 8000/4000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Jimmy and his friends like to visit large theme parks. In the current theme park there are many roller coasters which then are categorized by Jimmy. He assigns a fun value to each coaster; however, the fun decreases with each run.

    More formal: for a specific roller coaster i, Jimmy assigns two fun coefficients ai and bi. While riding this roller coaster for the k-th time, Jimmy gains a fun value of f(i, k) = ai - (k - 1)2* bi. If f(i, k) is non-positive, riding the roller coaster is no longer funny.

    Jimmy tries to maximize the total fun until he leaves the park. Can you tell Jimmy how much fun he can gain for a given time?

    输入

    The input consists of a single test case.

    The first line contains the integer N, where N is the amount of different roller coasters in the theme park (0 < N ≤ 100).

    The following N lines contain the integers ai, bi and ti where ai and bi are the fun coefficients as specified above and ti is the time for a single ride with the i-th roller coaster (0 ≤ ai ≤ 1000; 0 ≤ bi ≤ 1000; 0 < ti ≤ 25000).

    The next line contains a positive integer Q denoting the number of times that Jimmy is visiting the park (0 ≤ Q ≤ 1000). Each of the following Q lines contains an integral time Ti that Jimmy spends during his i-th visit (0 ≤ Ti ≤ 25000).

    输出

    Description

    Jimmy and his friends like to visit large theme parks. In the current theme park there are many roller coasters which then are categorized by Jimmy. He assigns a fun value to each coaster; however, the fun decreases with each run.

    More formal: for a specific roller coaster i, Jimmy assigns two fun coefficients ai and bi. While riding this roller coaster for the k-th time, Jimmy gains a fun value of f(i, k) = ai - (k - 1)2* bi. If f(i, k) is non-positive, riding the roller coaster is no longer funny.

    Jimmy tries to maximize the total fun until he leaves the park. Can you tell Jimmy how much fun he can gain for a given time?

    Input

    The input consists of a single test case.

    The first line contains the integer N, where N is the amount of different roller coasters in the theme park (0 < N ≤ 100).

    The following N lines contain the integers ai, bi and ti where ai and bi are the fun coefficients as specified above and ti is the time for a single ride with the i-th roller coaster (0 ≤ ai ≤ 1000; 0 ≤ bi ≤ 1000; 0 < ti ≤ 25000).

    The next line contains a positive integer Q denoting the number of times that Jimmy is visiting the park (0 ≤ Q ≤ 1000). Each of the following Q lines contains an integral time Ti that Jimmy spends during his i-th visit (0 ≤ Ti ≤ 25000).

    Output

    For each of the Q possible times, print one line containing the maximal total fun value if Jimmy spends Ti minutes in the theme park.

    Sample Input

    Sample #1
    2
    5 0 5
    7 0 7
    4
    88
    5
    6
    7


    Sample #2
    1
    100 3 2
    5
    2
    3
    4
    5
    100

    Sample Output

    Sample #1
    88
    5
    5
    7


    Sample #2
    100
    100
    197
    197
    435

    Source

    样例输入

    Sample #1
    2
    5 0 5
    7 0 7
    4
    88
    5
    6
    7


    Sample #2
    1
    100 3 2
    5
    2
    3
    4
    5
    100

    样例输出

    Sample #1
    88
    5
    5
    7


    Sample #2
    100
    100
    197
    197
    435

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部