No.3188 K-th Lexmin
Problem Statement
You are given a sequence of non-negative integers $A = (A_1, A_2, \cdots, A_N)$ of length $N$.
$A$ has $\frac{N(N + 1)}{2}$ contiguous subarrays. When they are arranged in lexicographic order, output the contiguous subarray at the $K$-th position.
You are given $T$ test cases; find the answer for each of them.
Input
$T$Here, $\mathrm{case}_i$ denotes the $i$-th test case, and each test case is given in the following format.
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
$N\ \ K$
$A_1\ \ A_2\ \ \cdots A_N$
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq K \leq \frac{N(N + 1)}{2}$
- $1 \leq A_i \leq N$
- All input values are integers.
- In $1$ input file, the sum of $N$ does not exceed $5 \times 10^5$.
Output
For each test case, output the contiguous subarray at the $K$-th position in lexicographic order, separated by spaces, followed by a newline.
Sample
Sample 1
Input
3
3 4
2 1 2
4 4
1 2 3 4
17 100
12 3 6 5 6 11 13 1 2 8 2 13 1 14 1 8 7
Output
2
1 2 3 4
8 2 13 1 14 1
For the $1$-st test case, the contiguous subarrays of $A$ are the following $6$: $(2), (2, 1), (2, 1, 2), (1), (1, 2), (2)$. Arranged in lexicographic order, they are $(1), (1, 2), (2), (2), (2, 1), (2, 1, 2)$. The $4$-th of these is $(2)$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂