大和証券プログラミングコンテスト2021 (AtCoder Regular Contest 128)
翻译中…
Problem Statement
翻译中…
Given are a sequence of $N$ integers $A=(A_1,A_2,\cdots,A_N)$ and an integer $K$.
翻译中…
Consider making a sequence of integers $x$ that satisfies both of the following conditions.
翻译中…
- For each integer
$i$($1 \leq i \leq N$),$x$contains exactly$A_i$occurrences of$i$.$x$does not contain other integers. - For every way of choosing
$K$consecutive elements from$x$, their values are all distinct.
翻译中…
Determine whether it is possible to make $x$ that satisfies the conditions. If it is possible, find the lexicographically smallest such $x$.
翻译中…
Constraints
翻译中…
$2 \leq K \leq N \leq 500$$1 \leq A_i$$\sum_{1 \leq i \leq N} A_i \leq 200000$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N K
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
If it is impossible to make a sequence $x$ that satisfies the conditions, print -1. If it is possible, print the lexicographically smallest such $x$.
翻译中…
样例
Input #1
3 3
2 2 1
Output #1
1 2 3 1 2
Two sequences $x=(1,2,3,1,2),(2,1,3,2,1)$ satisfy the conditions. The lexicographically smaller one, $(1,2,3,1,2)$, is the answer.
Input #2
3 2
2 1 2
Output #2
1 2 3 1 3
Input #3
3 3
1 3 3
Output #3
-1
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。