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

27100번 - Stamps 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB195625436.486%

문제

You are supplied a set of values for stamps (e.g., {1, 3, 5}) and the maximum number of stamps that can be applied to an envelope (e.g., five stamps). Your goal is to calculate the largest contiguous set of postage that can be accommodated. For the set of {1, 3, 5} with five maximum stamps, one can build:

  • 1: 1
  • 2: 1+1
  • 3: 3
  • 4: 1+3
  • 5: 5
  • 6: 1+5
  • 7: 5+1+1
  • 8: 5+3
  • 9: 5+3+1
  • 10: 5+5
  • 11: 5+5+1
  • 12: 5+5+1+1
  • 13: 5+5+3
  • 14: 5+5+3+1
  • 15: 5+5+5
  • 16: 5+5+3+3
  • 17: 5+5+5+1+1
  • 18: 5+5+5+3
  • 19: 5+5+5+3+1
  • 20: 5+5+5+5
  • 21: 5+5+5+3+3
  • 22: ????

There appears to be no way to build 22 cents with no more than five members of this set of stamps. Thus, one can build values in the ragen [1..21,] a total of 21 contiguous stamp values. There is no reason to believe that the largest contiguous set will start with the value '1'.

입력

  • Line 1: Two space separated integers, S (1 ≤ S ≤ 20), the number of stamp types, and E (1 ≤ E ≤ 10), the maximum number of stamps that can fit on an envelope.
  • Line 2: S different space-separated positive integers representing the values of the stamps (1 ≤ stampval ≤ 1000)

출력

The maximum number of contiguous values that can be created by combining the stamps.

제한

예제 입력 1

3 5
1 3 5

예제 출력 1

21

힌트

출처

Olympiad > USA Computing Olympiad > 1999-2000 Season > USACO Spring 2000 Contest > Orange 3번

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

출처

대학교 대회

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

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