CF1354F Summoning Minions
Description
Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other.
Polycarp can summon $ n $ different minions. The initial power level of the $ i $ -th minion is $ a_i $ , and when it is summoned, all previously summoned minions' power levels are increased by $ b_i $ . The minions can be summoned in any order.
Unfortunately, Polycarp cannot have more than $ k $ minions under his control. To get rid of unwanted minions after summoning them, he may destroy them. Each minion can be summoned (and destroyed) only once.
Polycarp's goal is to summon the strongest possible army. Formally, he wants to maximize the sum of power levels of all minions under his control (those which are summoned and not destroyed).
Help Polycarp to make up a plan of actions to summon the strongest possible army!
Input Format
N/A
Output Format
N/A
Explanation/Hint
Consider the example test.
In the first test case, Polycarp can summon the minion $ 2 $ with power level $ 7 $ , then summon the minion $ 1 $ , which will increase the power level of the previous minion by $ 3 $ , then destroy the minion $ 1 $ , and finally, summon the minion $ 5 $ . After this, Polycarp will have two minions with power levels of $ 10 $ .
In the second test case, Polycarp can control only one minion, so he should choose the strongest of them and summon it.
In the third test case, Polycarp is able to summon and control all five minions.