第二题用的贪心 if __name__ == "__main__": n, m = list(map(int, input().strip().split(' &(5528)#39;))) T = list(map(int, input().strip().split(' &(5528)#39;))) have = set(T) not_have = [] for i in range(1, n + 1): if i not in have: not_have.append(i) i, j = 0, 0 ans = [] while i < m and j < n - m: if T[i] < not_have[j]: ans.append(T[i]) i += 1 else: ans.append(not_have[j]) j += 1 while i < m: ans.append(T[i]) i += 1 while j < n - m: ans.append(not_have[j]) j += 1 s = ' &(5528)#39;.join(map(str, ans)) print(s)