[Solution] Traps Codeforces Solution | Codeforces Problem Solution 2022
There are traps numbered from to . You will go through them one by one in order. The -th trap deals base damage to you.
Instead of going through a trap, you can jump it over. You can jump over no more than traps. If you jump over a trap, it does not deal any damage to you. But there is an additional rule: if you jump over a trap, all next traps damages increase by (this is a bonus damage).
Note that if you jump over a trap, you don't get any damage (neither base damage nor bonus damage). Also, the bonus damage stacks so, for example, if you go through a trap
with base damage , and you have already jumped over traps, you get damage.
You have to find the minimal damage that it is possible to get if you are allowed to jump over no more than traps.
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The first line of each test case contains two integers and (, ) — the number of traps and the number of jump overs that you are allowed to make.
The second line of each test case contains integers () — base damage values of all traps.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case output a single integer — the minimal total damage that it is possible to get if you are allowed to jump over no more than traps.
No comments:
Post a Comment