atcoder#AGC062C. [AGC062C] Mex of Subset Sum

[AGC062C] Mex of Subset Sum

Score : 800800 points

Problem Statement

You are given an integer sequence of length NN: A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N).

Find the KK smallest positive integers XX that satisfy the following condition.

  • There is no non-empty (not necessarily contiguous) subsequence of AA whose elements sum to XX.

Constraints

  • 1N601 \leq N \leq 60
  • 1K10001 \leq K \leq 1000
  • 1Ai10151 \leq A_i \leq 10^{15}
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \dots ANA_N

Output

Print the KK smallest positive integers satisfying the conditions in ascending order, separated by spaces.

3 3
1 2 5
4 9 10

The subsequences of AA are (1),(2),(1,2),(5),(1,5),(2,5),(1,2,5)(1),(2),(1,2),(5),(1,5),(2,5),(1,2,5), and their respective sums are 1,2,3,5,6,7,81,2,3,5,6,7,8. Therefore, for X=1,2,3,5,6,7,8X=1,2,3,5,6,7,8, there are subsequences of AA whose elements sum to XX.

On the other hand, for X=4,9,10X=4,9,10, there is no subsequence of AA whose elements sum to XX.

20 10
324 60 1 15 60 15 1 60 319 1 327 1 2 60 2 345 1 2 2 15
14 29 44 59 74 89 104 119 134 149