[Solution] The Enchanted Forest Codeforces Solution | Codeforces Problem Solution 2022
Marisa comes to pick mushrooms in the Enchanted Forest.
The Enchanted forest can be represented by points on the -axis numbered through . Before Marisa started, her friend, Patchouli, used magic to detect the initial number of mushroom on each point, represented by .
Marisa can start out at any point in the forest on minute . Each minute, the followings happen in order:
- She moves from point to (, possibly ).
- She collects all mushrooms on point .
- A new mushroom appears on each point in the forest.
Note that she cannot collect mushrooms on minute .
Now, Marisa wants to know the maximum number of mushrooms she can pick after minutes.
Each test contains multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers , (, ) — the number of positions with mushrooms and the time Marisa has, respectively.
The second line of each test case contains integers () — the initial number of mushrooms on point .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print the maximum number of mushrooms Marisa can pick after minutes.
No comments:
Post a Comment