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

13984번 - Contest Score 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB131736859.130%

문제

You are participating in the Association for Computing Machinery’s Intercollegiate Programming Competition (ACM ICPC). You must complete a set of n problems. Since you are an experienced problem solver, you can read a problem and accurately estimate how long it will take to solve it, in a negligible amount of time. But you can only keep the details from k problems straight at any given time.

Let ti be the time it will take to solve the ith problem. Your strategy for the contest is as follows:

  1. Read the first k problems.
  2. Choose a problem that you have read that will take the shortest time to solve (if there are ties, choose any of them arbitrarily).
  3. Solve the problem, and read the next unread problem (if there is any).
  4. If there are still unsolved problems, go back to step 2.

You want to calculate your total penalty time for the contest. Your penalty time for the contest is defined by the sum of submission times for all the problems. Given the ordering of problems in the contest, compute the penalty time of your strategy.

입력

The first line of input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 300).

The ith line of the next n lines contains a single integer ti (1 ≤ ti ≤ 1,000,000).

출력

Print, on a single line, a single integer repesenting the total penalty time.

제한

예제 입력 1

4 3
1
3
2
1

예제 출력 1

14

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2016 Pacific Northwest Region Programming Contest > Division 2 Q번

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

출처

대학교 대회

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

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