This repository has been archived on 2026-05-22. You can view files and clone it, but cannot push or open issues or pull requests.
Files
NAIPC-2018/gnomes.py
2018-03-25 22:52:29 -04:00

27 lines
479 B
Python

n, m = map(int, input().split())
dat = [int(input()) for _ in range(m)]
sdat = set(dat)
missing = [x for x in range(1, n + 1) if x not in sdat]
res = []
i = 0
j = 0
while i < len(dat) and j < len(missing):
if dat[i] < missing[j]:
res.append(dat[i])
i += 1
else:
res.append(missing[j])
j += 1
while i < len(dat):
res.append(dat[i])
i += 1
while j < len(missing):
res.append(missing[j])
j += 1
for x in res:
print(x)