AtCoder Regular Contest 130
E
Increasing Minimum
AtCoder
⌀ 3188
原题
← DF →
翻译中…

Problem Statement

翻译中…

Consider doing the operation below on a sequence of $N$ positive integers $A = (A_1, A_2, \ldots, A_N)$ to obtain a sequence $I = (i_1, i_2, \ldots, i_K)$.

翻译中…
  • For each $k = 1, 2, \ldots, K$ in this order, do the following.
  • Choose an $i$ such that $A_i = \min\{A_1, A_2, \ldots, A_N\}$.
    • Let $i_k = i$.
    • Add $1$ to $A_i$.
翻译中…

You are given integers $N$, $K$, and a sequence $I$.

翻译中…

Determine whether there exists a sequence of positive integers $A$ for which it is possible to obtain $I$ from the operation. If it exists, find the lexicographically smallest such sequence.

翻译中…

Constraints

翻译中…
  • $1\leq N, K\leq 3\times 10^5$
  • $1\leq i_k\leq N$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
i_1 i_2 \ldots i_K

翻译中…

Output

翻译中…

If there is no sequence of positive integers $A$ for which it is possible to obtain $I$ from the operation, print -1. If it exists, print the lexicographically smallest among such sequences $A$, in one line, with spaces in between.

翻译中…

样例

Input #1
4 6
1 1 4 4 2 1
Output #1
1 3 3 2
Some of the sequences for which it is possible to obtain $I = (1,1,4,4,2,1)$ from the operation are $(1, 3, 3, 2)$ and $(2, 4, 5, 3)$. The lexicographically smallest among them is $(1, 3, 3, 2)$.
Input #2
4 6
2 2 2 2 2 2
Output #2
6 1 6 6
Input #3
4 6
1 1 2 2 3 3
Output #3
-1
题目信息
题号
arc130_e
时间限制
2 s
内存限制
1024 MB

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