CF67B.Restoration of the Permutation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let A=a1,a2,...,anA={a_{1},a_{2},...,a_{n}} be any permutation of the first nn natural numbers 1,2,...,n{1,2,...,n} . You are given a positive integer kk and another sequence B=b1,b2,...,bnB={b_{1},b_{2},...,b_{n}} , where bib_{i} is the number of elements aja_{j} in AA to the left of the element at=ia_{t}=i such that aj>=(i+k)a_{j}>=(i+k) .

For example, if n=5n=5 , a possible AA is 5,1,4,2,3{5,1,4,2,3} . For k=2k=2 , BB is given by 1,2,1,0,0{1,2,1,0,0} . But if k=3k=3 , then B=1,1,0,0,0B={1,1,0,0,0} .

For two sequences X=x1,x2,...,xnX={x_{1},x_{2},...,x_{n}} and Y=y1,y2,...,ynY={y_{1},y_{2},...,y_{n}} , let ii -th elements be the first elements such that xiyix_{i}≠y_{i} . If x_{i}<y_{i} , then XX is lexicographically smaller than YY , while if x_{i}>y_{i} , then XX is lexicographically greater than YY .

Given nn , kk and BB , you need to determine the lexicographically smallest AA .

输入格式

The first line contains two space separated integers nn and kk ( 1<=n<=10001<=n<=1000 , 1<=k<=n1<=k<=n ). On the second line are nn integers specifying the values of B=b1,b2,...,bnB={b_{1},b_{2},...,b_{n}} .

输出格式

Print on a single line nn integers of A=a1,a2,...,anA={a_{1},a_{2},...,a_{n}} such that AA is lexicographically minimal. It is guaranteed that the solution exists.

输入输出样例

  • 输入#1

    5 2
    1 2 1 0 0
    

    输出#1

    4 1 5 2 3 
  • 输入#2

    4 2
    1 0 0 0
    

    输出#2

    2 3 1 4 
首页