| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2.5 초 | 1024 MB | 8 | 0 | 0 | 0.000% |
You are given $N$ numbers – $v_1, v_2, \dots , v_N,ドル and an integer $A$. You can do an unlimited number of swaps in the array by swapping $v_i$ and $v_{i+1}$ for a cost of $v_i + v_{i+1}$. The new array after the swap would then be $v1, \dots , v_{i+1}, v_i , \dots , v_N$. For a certain number $R,ドル your task it to find the minimum sum of the costs of your swaps and $(v_1 + v_2 + \cdots + v_R) \times A$. Given $Q$ queries and an $R_i$ for each of them, find the minimum cost you can achieve for each query. All queries are independent.
There are 3ドル$ integers on the first line: $N$ – the size of the array, $Q$ – the number of queries and $A$ – the coefficient $(v_1 + v_2 + \cdots + v_R)$ is multiplied by. The second line of the input contains $N$ positive integers $v_1, v_2, \dots , v_N$ - the starting array. The last line holds the positive integers $R_1, \dots , R_Q$.
On each of the $Q$ lines output the minimum cost for the corresponding query.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 5 | $N ≤ 8,ドル $Q = 1$ |
| 2 | 10 | $N ≤ 5000,ドル $Q = 1$ |
| 3 | 25 | $N ≤ 10^6,ドル $Q = 1$ |
| 4 | 10 | $N ≤ 1.5 \times 10^4$ |
| 5 | 50 | $N ≤ 5 \times 10^4$ |
4 1 5 4 1 2 3 2
25
4 1 6 4 1 2 3 2
29
Example No1: It is optimal to not swap any elements. The cost is then $(4 + 1) \times 5 = 25$.
Example No2: We can first swap 4ドル$ with 1ドル$ and then 4ドル$ with 2ドル$:
The costs of the swaps are 4ドル + 1 = 5$ and 4ドル + 2 = 6$. Therefore, the total cost is
5ドル + 6 + (1 + 2) \times 6 = 29$.