| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 61 | 35 | 25 | 60.976% |
Yuta has a sequence of $n$ positive integers $A_1, \ldots, A_n,ドル and their sum is $m$. For each subsequence $S$ of $A,ドル he calculated the sum of elements in this subsequence.
So, now Yuta has also got 2ドル^n$ integers between 0ドル$ and $m$. For each $i \in [0, m],ドル let $B_i$ be the number of integers $i$ he got.
Yuta shows you the array $B_i,ドル and he asks you to restore $A_1, \ldots, A_n$. If there are several possibilities, find the lexicographically smallest possible sequence.
The first line of the input contains two integers $n$ and $m$ (1ドル \leq n \leq 50,ドル 1ドル \leq m \leq 10^4$).
The second line contains $m + 1$ integers $B_0, \ldots, B_m$ (0ドル \leq B_i \leq 2^n$).
Print a single line with $n$ integers $A_1, \ldots, A_n$.
It is guaranteed that there exists at least one solution. And if there are several possible solutions, print the lexicographically smallest one.
2 3 1 1 1 1
1 2
3 3 1 3 3 1
1 1 1
In the first example, $A$ is $[1, 2]$. $A$ has four subsequences $[],ドル $[1],ドル $[2]$ and $[1,2],ドル and the sums for them are 0ドル,ドル 1ドル,ドル 2ドル$ and 3ドル$. So, $B = [1, 1, 1, 1]$.