Codeforces Global Round 25 |
---|
Finished |
As the CEO of a startup company, you want to reward each of your $$$k$$$ employees with a ticket to the upcoming concert. The tickets will be on sale for $$$n$$$ days, and by some time travelling, you have predicted that the price per ticket at day $$$i$$$ will be $$$a_i$$$. However, to prevent ticket hoarding, the concert organizers have implemented the following measures:
For example, if $$$a = [1, 3, 8, 4, 5]$$$ and you purchase $$$2$$$ tickets on day $$$1$$$, they will cost $$$2$$$ in total, and the prices from day $$$2$$$ onwards will become $$$[5, 10, 6, 7]$$$. If you then purchase $$$3$$$ more tickets on day $$$2$$$, they will cost in total an additional $$$15$$$, and the prices from day $$$3$$$ onwards will become $$$[13, 9, 10]$$$.
Find the minimum spending to purchase $$$k$$$ tickets.
Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1 \le n \le 3 \cdot 10^5, 1 \le m \le 10^9, 1 \le k \le \min(nm, 10^9)$$$) — the number of sale days, the maximum amount of ticket purchasable each day, and the number of tickets to be bought at the end.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the price per ticket for each of the upcoming $$$n$$$ days.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.
For each test case, print one integer: the minimum amount of money needed to purchase exactly $$$k$$$ tickets.
44 2 38 6 4 24 2 88 6 4 25 100 110000 1 100 10 10006 3 95 5 5 5 5 5
10 64 1 72
In the first test case, one optimal way to buy $$$3$$$ tickets is as follows:
In the second test case, there is only one way to buy $$$8$$$ tickets:
Name |
---|