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

31893번 - Bridging the Gap 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB104373053.571%

문제

A group of walkers arrives at a river in the night. They want to cross a bridge, which can hold a limited number of walkers at a time. The walkers have just one torch, which needs to be used when crossing the bridge. Each walker takes a certain time to cross; a group crossing together must walk at the slowest walker’s pace. What is the shortest time it takes for all walkers to cross the bridge?

For example, Sample Input 1 assumes the bridge can hold 2ドル$ walkers at a time and there are 4ドル$ walkers with crossing times 1ドル$ minute, 2ドル$ minutes, 5ドル$ minutes and 10ドル$ minutes, respectively. The shortest time of 17ドル$ minutes can be achieved by the following sequence of crossings. First, the two fastest walkers cross in 2ドル$ minutes. Second, the fastest walker crosses back in 1ドル$ minute. Third, the two slowest walkers cross in 10ドル$ minutes. Fourth, the second-fastest walker crosses back in 2ドル$ minutes. Fifth, the two fastest walkers cross in 2ドル$ minutes.

입력

The first line of input contains two integers $n$ and $c,ドル where $n$ (2ドル≤n≤10^4$) is the number of walkers, and $c$ (2ドル≤c≤10^4$) is the number of walkers the bridge can hold at a time.

Then follows a line containing $n$ integers $t_1,\dots ,t_n$ (1ドル≤t_i≤10^9$ for all $i$). The $i$th walker takes time $t_i$ to cross.

출력

Output the minimum total time it takes for the entire group to cross the bridge.

제한

예제 입력 1

4 2
1 2 10 5

예제 출력 1

17

예제 입력 2

4 6
1 2 10 5

예제 출력 2

10

힌트

출처

ICPC > World Finals > ICPC World Finals 2022 S번

ICPC > World Finals > ICPC World Finals 2023 J번

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

출처

대학교 대회

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

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