No.2560 A_1 < A_2 < ... < A_N
タグ : / 解いたユーザー数 278
作問者 :
Kyo_s_s
/ テスター :
kusirakusira
Magentor
DeltaStruct
👑
bluebery1001
rotti_coder
ragna
けんぴん
Problem Statement
You are given positive integers $N, X$. Determine whether there exists a sequence $A_1, A_2, \ldots, A_N$ consisting of $N$ positive integers that satisfies all of the following conditions:
- $0 < A_1 < A_2 < \cdots < A_{N-1} < A_N$
- $\displaystyle \sum_{i=1}^N A_i = X$
If such a sequence exists, output the lexicographically smallest one.
You are given $T$ test cases; solve each of them.
What is the lexicographic order for sequences of equal length?
For $2$ integer sequences of equal length $A=(A_1,A_2,\ldots ,A_N)$ and $B=(B_1,B_2,\ldots ,B_N)$, $A < B$ in lexicographic order is defined to hold if and only if the following is satisfied.- There exists an integer $i \ (1 \le i \le N)$ such that $A_j = B_j$ holds for all integers $j$ with $1 \le j < i$, and $A_i < B_i$ holds.
Constraints
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq X \leq 10^{18}$
- For the test cases contained in $1$ input, the sum of their $N$ is at most $2 \times 10^5$
- All input values are integers
Input
The input is given from standard input in the following format.
$T$
$\text{case}_1$
$\vdots$
$\text{case}_T$
Each test case $\text{case}_i~(1 \leq i \leq T)$ is given in the following format.
$N ~ X$
Output
Output $T$ lines. On the $i$-th line, if a sequence satisfying the conditions exists for test case $\text{case}_i$, output that sequence separated by spaces on $1$ line; otherwise, output $-1$.
Sample
Sample 1
Input
3 4 10 3 5 3 9
Output
1 2 3 4 -1 1 2 6
- For test case $1$, the only sequence satisfying the $2$ conditions in the problem statement is $(1, 2, 3, 4)$. Therefore, output this.
- For test case $2$, no sequence satisfies the $2$ conditions in the problem statement. Therefore, output $-1$.
-
For test case $3$, the sequences satisfying the $2$ conditions in the problem statement are
- $(1, 2, 6)$
- $(1, 3, 5)$
- $(2, 3, 4)$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。