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

15379번 - Guardians of the Lunatics 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 (추가 시간 없음) 512 MB171524139.806%

문제

You are in charge of assigning guards to a prison where the craziest criminals are sent. The L cells form a single row and are numbered from 1 to L. Cell i houses exactly one lunatic whose craziness level is Ci.

Each lunatic should have one guard watching over him/her. Ideally, you should have one guard watching over each lunatic. However, due to budget constraints, you only have G guards to assign. You have to assign which lunatics each guard should watch over in order to minimize the total risk of having someone escape.

Of course, you should assign each guard to a set of adjacent cells. The risk level Ri that the lunatic in cell i can escape is given by the product of his/her craziness level Ci and the number of lunatics the guard assigned to him/her is watching over. Getting the sum of the Ri’s from i = 1 to i = L will give us the total amount of risk, R, that a lunatic might escape.

Given L lunatics and G guards, what is the minimum possible value of R?

입력

The first line of input contains a single integer, T, denoting the number of test cases.

The first line of each test case contains two space-separated positive integers: L and G, the number of lunatics and the number of guards respectively. The next L lines describe the craziness level of each of the lunatics. The ith of these L lines describe the craziness level of the lunatic in cell block i.

Constraints

  • 1 ≤ T ≤ 22
  • 1 ≤ L ≤ 8000
  • 1 ≤ G ≤ 800
  • 1 ≤ Ci ≤ 109

출력

For each test case, output a line containing the minimum possible value of R.

제한

예제 입력 1

1
6 3
11
11
11
24
26
100

예제 출력 1

299

힌트

출처

ICPC > Regionals > Asia Pacific > Philippines > 2016 ACM-ICPC Asia-Manila Regional Programming Contest 연습 세션 PH번

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

출처

대학교 대회

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

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