CF415A.Mashmokh and Lights
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
马什莫赫在一家工厂工作。每天结束时,他必须关闭所有灯。
工厂中的灯编号为 1 到 n。马什莫赫的房间中也有 n 个按钮,编号同样为 1 到 n。如果马什莫赫按下编号为 i 的按钮,则所有编号不小于 i 且当前仍处于开启状态的灯都会被关闭。
马什莫赫并不十分聪明,因此他每晚并非按顺序从第一个按钮开始按,而是随机按下若干按钮。今晚,他依次按下了 m 个互不相同的按钮:b1,b2,…,bm(按此给定顺序连续按下)。现在他想知道:对每一盏灯,是哪一个按钮将其关闭的。请注意,按钮 bi 的编号实际上是 bi,而非 i。
请帮助马什莫赫,输出这些编号。
输入格式
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.
输入的第一行包含两个用空格分隔的整数 n 和 m(1 ≤ n, m ≤ 100),分别表示工厂中灯的数量和被按下的按钮数量。
下一行包含 m 个互不相同的、用空格分隔的整数 b1,b2,…,bm(1 ≤ bi ≤ n)。
保证在按下所有按钮后,所有灯都将被关闭。
输出格式
Output n space-separated integers where the i-th number is index of the button that turns the i-th light off.
输出 n 个空格分隔的整数,其中第 i 个数表示关闭第 i 盏灯所对应的按钮的索引。
输入输出样例
输入#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
说明/提示
In the first sample, after pressing button number 4, lights 4 and 5 are turned off and lights 1, 2 and 3 are still on. Then after pressing button number 3, light number 3 is turned off as well. Pressing button number 1 turns off lights number 1 and 2 as well so pressing button number 2 in the end has no effect. Thus button number 4 turned lights 4 and 5 off, button number 3 turned light 3 off and button number 1 turned light 1 and 2 off.
在第一个样例中,按下编号为 4 的按钮后,灯 4 和灯 5 被关闭,而灯 1、2 和 3 仍处于开启状态。接着按下编号为 3 的按钮,灯 3 也被关闭。再按下编号为 1 的按钮,灯 1 和灯 2 同样被关闭,因此最后按下编号为 2 的按钮不会产生任何效果。综上,编号为 4 的按钮关闭了灯 4 和灯 5,编号为 3 的按钮关闭了灯 3,编号为 1 的按钮关闭了灯 1 和灯 2。
输入解题思路,AI测评打分。不知道怎么写?