AT_ndpc2026_o.Game
入门
通过率:0%
时间限制:4.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are going to play a game. The game consists of actions over N days. Each day, you choose an integer x∈0,1,2, pay x yen, and perform action x. If you perform action x on day i, you gain Ai,x experience points. You cannot perform more than one action per day.
You are given Q queries. In each query, you are given a pair of integers (d,b) such that 1≤d≤N and 0≤b≤2d. Solve the following problem:
- Suppose you spend exactly b yen in total from day 1 to day d. What is the maximum possible total experience you can gain during these d days?
You are given T test cases. Solve each of them.
你将进行一场游戏。游戏持续 N 天,每天你需要执行一个操作。每天,你需选择一个整数 x∈{0,1,2},支付 x 日元,并执行操作 x。若在第 i 天执行操作 x,你将获得 Ai,x 点经验值。每天至多只能执行一个操作。
你将收到 Q 个查询。每个查询给出一对整数 (d,b),满足 1≤d≤N 且 0≤b≤2d。请解决如下问题:
- 假设你在第 1 天至第 d 天期间恰好总共花费 b 日元,那么这 d 天内你能获得的最大总经验值是多少?
你将收到 T 组测试数据,请对每组数据求解。
输入格式
The input is given from standard input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N Q
A1,0 A1,1 A1,2
A2,0 A2,1 A2,2
⋮
AN,0 AN,1 AN,2
query1
query2
⋮
queryQ
Each query is given in the following format:
d b
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N Q
A1,0 A1,1 A1,2
A2,0 A2,1 A2,2
⋮
AN,0 AN,1 AN,2
query1
query2
⋮
queryQ
每个查询按以下格式给出:
d b
输出格式
Output the answers for all test cases in order.
For each test case, print Q lines. On the i-th line, output the answer to the i-th query.
按顺序输出所有测试用例的答案。
对于每个测试用例,输出 Q 行。在第 i 行输出第 i 个查询的答案。
输入输出样例
输入#1
2 3 3 1 3 2 4 8 1 1 6 9 1 1 2 3 3 3 5 5 45 58 82 47 39 94 36 54 74 80 61 95 61 57 69 2 4 5 7 4 1 5 5 3 0
输出#1
3 10 18 176 387 226 371 128
输入#2
1 10 10 76 30 16 30 94 48 60 67 90 43 63 47 49 33 66 14 49 79 39 62 37 34 79 96 29 86 85 59 42 69 10 16 10 13 10 8 10 20 10 2 10 5 10 4 10 0 10 15 10 19
输出#2
764 770 724 633 554 664 634 433 780 679
说明/提示
Partial Score
This problem has partial scoring.
- If all queries satisfy d=N, you will get 5 points.
Sample 1 Explanation:
For example, consider the 3-rd query of the first test case: d=3,b=3.
You can achieve a total experience of 18 in the following way, which is optimal:
- Day 1: choose x=0. Pay 0 yen and gain A1,0=1 experience.
- Day 2: choose x=1. Pay 1 yen and gain A2,1=8 experience.
- Day 3: choose x=2. Pay 2 yen and gain A3,2=9 experience.
Constraints
- 1≤T≤104
- 1≤N≤2.5×105
- 1≤Q≤104
- 0≤Ai,x≤109
- 1≤d≤N
- 0≤b≤2d
- The sum of N over all test cases is at most 2.5×105
- The sum of Q over all test cases is at most 104
- All input values are integers
部分得分
本题采用部分得分制。
- 若所有查询均满足 d=N,则可获得 5 分。
样例 1 解释:
例如,考虑第一个测试用例的第 3 个查询:d=3, b=3。
以下方式可获得总计 18 点经验,且该方案为最优:
- 第 1 天:选择 x=0。花费 0 日元,获得 A1,0=1 点经验。
- 第 2 天:选择 x=1。花费 1 日元,获得 A2,1=8 点经验。
- 第 3 天:选择 x=2。花费 2 日元,获得 A3,2=9 点经验。
限制条件
- 1≤T≤104
- 1≤N≤2.5×105
- 1≤Q≤104
- 0≤Ai,x≤109
- 1≤d≤N
- 0≤b≤2d
- 所有测试用例的 N 之和不超过 2.5×105
- 所有测试用例的 Q 之和不超过 104
- 所有输入值均为整数
输入解题思路,AI测评打分。不知道怎么写?