Logo
(追記) (追記ここまで)

28480번 - Reorder 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2.5 초 1024 MB8000.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ドル ≤ Q, R_i ≤ N$
  • 1ドル ≤ v_i , A ≤ 10^6$

서브태스크

번호배점제한
15

$N ≤ 8,ドル $Q = 1$

210

$N ≤ 5000,ドル $Q = 1$

325

$N ≤ 10^6,ドル $Q = 1$

410

$N ≤ 1.5 \times 10^4$

550

$N ≤ 5 \times 10^4$

예제 입력 1

4 1 5
4 1 2 3
2

예제 출력 1

25

예제 입력 2

4 1 6
4 1 2 3
2

예제 출력 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ドル$:

  • $\color{red}{4}$ $\color{red}{1}$ 2ドル$ 3ドル$
  • 1ドル$ $\color{red}{4}$ $\color{red}{2}$ 3ドル$
  • 1ドル$ 2ドル$ 4ドル$ 3ドル$

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$.

출처

Olympiad > International Autumn Tournament in Informatics > 2022 > Group A (Seniors) 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /