No.2567 A_1 > A_2 > ... > A_N
タグ : / 解いたユーザー数 141
作問者 :
Kyo_s_s
/ テスター :
kusirakusira
Magentor
👑 Problem Statement
You are given positive integers $N, X$. Determine whether there exists a sequence $A_1, A_2, \ldots, A_N$ of $N$ positive integers that satisfies all of the following conditions:
- $A_1 > A_2 > \cdots > A_{N-1} > A_N > 0$
- $\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 of 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}$
- Over the test cases contained in $1$ input, the sum of $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 line $i$, if a sequence satisfying the conditions exists for test case $\text{case}_i$, output that sequence on $1$ line, separated by spaces; otherwise, output $-1$.
Sample
Sample 1
Input
3 4 10 3 5 3 9
Output
4 3 2 1 -1 4 3 2
- For test case $1$, the only sequence satisfying the $2$ conditions in the problem statement is $(4,3,2,1)$. Thus, output this sequence.
- For test case $2$, no sequence satisfies the $2$ conditions in the problem statement. Thus, output $−1$.
-
For test case $3$, the sequences satisfying the $2$ conditions in the problem statement are
- $(6, 2, 1)$
- $(5, 3, 1)$
- $(4, 3, 2)$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。