CF1914C.Quests
普及-
通过率:0%
时间限制:2.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Monocarp is playing a computer game. In order to level up his character, he can complete quests. There are n quests in the game, numbered from 1 to n.
Monocarp can complete quests according to the following rules:
- the 1-st quest is always available for completion;
- the i-th quest is available for completion if all quests j<i have been completed at least once.
Note that Monocarp can complete the same quest multiple times.
For each completion, the character gets some amount of experience points:
- for the first completion of the i-th quest, he gets ai experience points;
- for each subsequent completion of the i-th quest, he gets bi experience points.
Monocarp is a very busy person, so he has free time to complete no more than k quests. Your task is to calculate the maximum possible total experience Monocarp can get if he can complete no more than k quests.
Monocarp 正在玩一款电脑游戏。为了提升角色等级,他可以完成任务。游戏中共有 n 个任务,编号从 1 到 n。
Monocarp 可以按照以下规则完成任务:
- 第 1 个任务始终可被完成;
- 第 i 个任务可被完成,当且仅当所有编号 j<i 的任务都至少已被完成过一次。
注意:Monocarp 可以多次完成同一个任务。
每次完成任务,角色会获得一定数量的经验值:
- 第 i 个任务首次完成时,获得 ai 点经验值;
- 第 i 个任务后续每次完成时,获得 bi 点经验值。
Monocarp 非常忙,因此他仅有时间完成至多 k 个任务。你的任务是:计算 Monocarp 在最多完成 k 个任务的前提下,所能获得的最大总经验值。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains two integers n and k (1≤n≤2⋅105; 1≤k≤2⋅105) — the number of quests and the maximum number of quests Monocarp can complete, respectively.
The second line contains n integers a1,a2,…,an (1≤ai≤103).
The third line contains n integers b1,b2,…,bn (1≤bi≤103).
Additional constraint on the input: the sum of n over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 k(1≤n≤2⋅105;1≤k≤2⋅105)—— 分别表示任务数量以及 Monocarp 最多能完成的任务数量。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤103)。
第三行包含 n 个整数 b1,b2,…,bn(1≤bi≤103)。
输入的额外约束:所有测试用例的 n 值之和不超过 2⋅105。
输出格式
For each test case, print a single integer — the maximum possible total experience Monocarp can get if he can complete no more than k quests.
对于每个测试用例,输出一个整数——即 Monocarp 最多完成 k 个任务时所能获得的最大总经验值。
输入输出样例
输入#1
4 4 7 4 3 1 2 1 1 1 1 3 2 1 2 5 3 1 8 5 5 3 2 4 1 4 2 3 1 4 7 6 4 1 4 5 4 5 10 1 5 1 2 5 1
输出#1
13 4 15 15
说明/提示
In the first test case, one of the possible quest completion sequences is as follows: 1,1,2,3,2,4,4; its total experience is equal to 4+1+3+1+1+2+1=13 (the underlined numbers correspond to the instances when we complete a quest for the first time).
In the second test case, one of the possible quest completion sequences is as follows: 1,1; its total experience is equal to 1+3=4.
In the third test case, one of the possible quest completion sequences is as follows: 1,2,2,2,3; its total experience is equal to 3+2+3+3+4=15.
在第一个测试用例中,一种可能的任务完成序列为:1,1,2,3,2,4,4;其总经验值为 4+1+3+1+1+2+1=13(下划线标出的数字对应首次完成该任务时所获得的经验值)。
在第二个测试用例中,一种可能的任务完成序列为:1,1;其总经验值为 1+3=4。
在第三个测试用例中,一种可能的任务完成序列为:1,2,2,2,3;其总经验值为 3+2+3+3+4=15。
输入解题思路,AI测评打分。不知道怎么写?