Codeforces Round 990 (Div. 1)
B
Move Back at a Cost
Codeforces
1600
原题
← AC →
翻译中…

You are given an array of integers $a$ of length $n$. You can perform the following operation zero or more times:

翻译中…
  • In one operation choose an index $i$ ($1 \le i \le n$), assign $a_i := a_i + 1$, and then move $a_i$ to the back of the array (to the rightmost position). For example, if $a = [3, 5, 1, 9]$, and you choose $i = 2$, the array becomes $[3, 1, 9, 6]$.
翻译中…

Find the lexicographically smallest$^{\text{∗}}$ array you can get by performing these operations.

翻译中…

$^{\text{∗}}$An array $c$ is lexicographically smaller than an array $d$ if and only if one of the following holds: $c$ is a prefix of $d$, but $c \ne d$; or in the first position where $c$ and $d$ differ, the array $c$ has a smaller element than the corresponding element in $d$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 10^5$), the length of the array.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$), the elements of the array.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, print the lexicographically smallest array you can get.

翻译中…

样例

Input #1
3
3
2 1 3
5
1 2 2 1 4
6
1 2 3 6 5 4
Output #1
1 3 3
1 1 3 3 5
1 2 3 4 6 7
InputCopy OutputCopy
题目信息
题号
2046B
时间限制
2 s
内存限制
256 MB
标签
二分
数据结构
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。