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

31508번 - Candy Factory 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 2048 MB200554733.099%

문제

The International Consortium of Popular Candies (ICPC) is hosting a prestigious candy festival for candy lovers worldwide. The consortium has asked $n$ candy factories to produce candies for the event. Each of the $n$ factories has produced some quantity of a unique type of candy.

Packs of candies will be given to the participants at the festival. A candy pack must consist of exactly $k$ candies of different types. Two candy packs may contain different sets of $k$ candies.

There may be unavoidably some leftover candies given the quantities of candies that the $n$ factories have already produced. The ICPC does not want to waste any of the candies produced, and is willing to create extra packs of candy to ensure this. The ICPC can order any of the $n$ factories to produce additional candies. What is the minimum quantity of additional candies that must be ordered, so that there will be no leftover candies after packing?

입력

The first line of input has two integers $n$ and $k$ (1ドル \leq k \leq n \leq 5,000円$).

The next $n$ lines each have a single integer between 1ドル$ and 10ドル^9$. The integer on the $i^{\text{th}}$ line is the quantity of candies that the $i^{\text{th}}$ factory has produced.

출력

Output a single integer, the minimum quantity of additional candies that must be ordered.

제한

예제 입력 1

4 3
1
3
4
1

예제 출력 1

3

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 1 C번

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 2 J번

  • 문제를 만든 사람: Bowen Yu
(追記) (追記ここまで)

출처

대학교 대회

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

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