302175: CF415A. Mashmokh and Lights
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Mashmokh and Lights
题意翻译
有编号为$1 - n$共$n$个灯。按下$i$号开关后,所有编号$\ge i$的灯都会被关掉。给出$n, m$两个数,分别表示灯的数量和按下的开关数,输出每个灯被第一次关掉时开关的编号。题目描述
Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are indexed from $ 1 $ to $ n $ . There are $ n $ buttons in Mashmokh's room indexed from $ 1 $ to $ n $ as well. If Mashmokh pushes button with index $ i $ , then each light with index not less than $ i $ that is still turned on turns off. Mashmokh is not very clever. So instead of pushing the first button he pushes some of the buttons randomly each night. He pushed $ m $ distinct buttons $ b_{1},b_{2},...,b_{m} $ (the buttons were pushed consecutively in the given order) this night. Now he wants to know for each light the index of the button that turned this light off. Please note that the index of button $ b_{i} $ is actually $ b_{i} $ , not $ i $ . Please, help Mashmokh, print these indices.输入输出格式
输入格式
The first line of the input contains two space-separated integers $ n $ and $ m $ $ (1<=n,m<=100) $ , the number of the factory lights and the pushed buttons respectively. The next line contains $ m $ distinct space-separated integers $ b_{1},b_{2},...,b_{m} (1<=b_{i}<=n) $ . It is guaranteed that all lights will be turned off after pushing all buttons.
输出格式
Output $ n $ space-separated integers where the $ i $ -th number is index of the button that turns the $ i $ -th light off.
输入输出样例
输入样例 #1
5 4
4 3 1 2
输出样例 #1
1 1 3 4 4
输入样例 #2
5 5
5 4 3 2 1
输出样例 #2
1 2 3 4 5