Cookies

AtCoder
IDabc440_e
Time2000ms
Memory256MB
Difficulty
There are $10^{100}$ cookies of each of $N$ types. The deliciousness per cookie of the $i$\-th type is $A_i$. You will choose a total of $K$ cookies from these. Two ways of choosing cookies are considered the same if and only if the multisets of types of chosen cookies match. For each of the $\binom{N+K-1}{K}$ ways of choosing, consider the sum of deliciousness of the chosen cookies. Let $S_1,S_2,\dots$ be these sums in descending order, with duplicates included. Find $S_1,\dots,S_X$. ## Constraints * $1\leq N \leq 50$ * $1 \leq K \leq 10^5$ * $1 \leq X \leq \min\left(10^5, \binom{N+K-1}{K}\right)$ * $-10^9 \leq A_i \leq 10^9$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $K$ $X$ $A_1$ $\dots$ $A_N$ [samples]
Samples
Input #1
2 4 3
20 10
Output #1
80
70
60

There are $5$ ways to choose $4$ cookies: "$k$ cookies of type $1$ and $4-k$ cookies of type $2$" $(0\leq k \leq 4)$, where the sums of deliciousness of the chosen cookies are $80,70,60,50,40$.
Input #2
3 100000 5
-1 -1 -1
Output #2
\-100000
-100000
-100000
-100000
-100000

Different ways of choosing cookies may result in the same sum of deliciousness.
Input #3
9 14142 13
31 41 59 26 53 58 97 93 23
Output #3
1371774
1371770
1371766
1371762
1371758
1371754
1371750
1371746
1371742
1371738
1371736
1371735
1371734
API Response (JSON)
{
  "problem": {
    "name": "Cookies",
    "description": {
      "content": "There are $10^{100}$ cookies of each of $N$ types. The deliciousness per cookie of the $i$\\-th type is $A_i$. You will choose a total of $K$ cookies from these. Two ways of choosing cookies are consid",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc440_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $10^{100}$ cookies of each of $N$ types. The deliciousness per cookie of the $i$\\-th type is $A_i$.\nYou will choose a total of $K$ cookies from these. Two ways of choosing cookies are consid...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments