QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22795. 우표

Statistics

우표 값 집합(예 {1, 3, 5})과 봉투 최대 우표 수(예 다섯)가 주어집니다. 만들 수 있는 가장 긴 연속 우편 요금 구간을 구하세요. {1, 3, 5}, 최대 다섯이면:

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

다섯 이하로 22센트를 만들 수 없어 보입니다. 따라서 $[1,21]$의 연속 값 21개를 만듭니다. 가장 긴 구간이 반드시 1에서 시작하지는 않습니다.

입력

  • $1$번 줄: 공백 구분 정수 $S$($1 \le S \le 20$), 종류 수, $E$($1 \le E \le 10$), 봉투 최대 우표 수.

  • $2$번 줄: 공백 구분 서로 다른 양의 정수 $S$개, 우표 값($1 \le \text{stampval} \le 1000$).

출력

우표 조합으로 만들 수 있는 연속 값 수의 최댓값.

예제

입력 1

3 5
1 3 5

출력 1

21

출처: 1995 ACM 결승.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.