#P1771. Restoration of the Permutation

Restoration of the Permutation

题目描述

给定正整数 n,kn,k 和序列 BB,需要构造一个字典序最小的序列 AA,满足 BAiB_{A_i}AiA_i 左边的所有数中 i+k≥i+k 的数量。

输入格式

第一行两个整数 n,kn,k1kn10001\le k\le n\le 1000

第二行 nn 个整数 BiB_i

输出格式

在一行中输出 nn 个整数,表示数组 AiA_i

5 2
1 2 1 0 0
4 1 5 2 3
4 2
1 0 0 0
2 3 1 4