A. Mashmokh and Lights
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 mdistinct buttons b1, b2, ..., bm (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 bi is actually bi, not i.

Please, help Mashmokh, print these indices.

Input

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 b1, b2, ..., bm (1 ≤ bi ≤ n).

It is guaranteed that all lights will be turned off after pushing all buttons.

Output

Output n space-separated integers where the i-th number is index of the button that turns the i-th light off.

Examples
input
5 4
4 3 1 2
output
1 1 3 4 4 
input
5 5
5 4 3 2 1
output
1 2 3 4 5 
Note

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.

 题意:按了某个按键a[i],>=a[i]的数字的灯都会被关掉(如果那只灯已经关了就不记录,也就是每个关的灯输出的都是让它第一次关的数字,做个标记就行了),输出第i只灯是按哪只灯时关掉的。

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[],b[]= {};
for(int i=; i<m; i++)
{
cin>>a[i];
for(int j=a[i]-; j<n; j++)
{
if(b[j]==)
b[j]=a[i];
}
}
for(int i=; i<n; i++)
{
printf("%d%c",b[i],i==n-?'\n':' ');
}
return ;
}

Codeforces Round #240 (Div. 2)->A. Mashmokh and Lights的更多相关文章

  1. Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP

                                                 B. Mashmokh and ACM                                     ...

  2. Codeforces Round #240 (Div. 2) C Mashmokh and Numbers

    , a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...

  3. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  4. Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)

    Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university ...

  5. Codeforces Round #240 (Div. 2) B 好题

    B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #240 (Div. 2) D

    , b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainde ...

  7. Codeforces Round #240 (Div. 2) 题解

    A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. VxWorks 6.9 内核编程指导之读书笔记 -- C++开发

    5.1 介绍 针对C++的VxWorks配置 C++头文件 使用C++启动任务 C和C++之前调用代码 C++编译器说明 在信号处理和ISR中使用C++ 下载C++编写的内核模块 C++编译器的不同 ...

  2. BeanDefinition的载入和解析

    1.在完成对代表BeanDefinition的Resource定位的分析后,下面来了解整个BeanDefinition信息的载入过程. 2.对IoC容器来说,这个载入过程,相当于把定义的BeanDef ...

  3. tar命令: 对某目录文件打tar包时,排除指定的目录或文件

     如某当前目录存在以下文件或目录: 1.txt2.txt3.txtdir1dir2my2015.tarmy2016.tar 若要对当前目录除1.txt 和dir1.tar外,打包tar 步骤一.建立e ...

  4. 7款HTML5的精美应用教程让你立即爱上HTML5

    1,HTML5/jQuery雷达动画图表图表配置十分简单 分享一款很特别的HTML5图表,它是利用HTML5和jQuery的雷达动画图表,图表数据在初始化的时候带有一定动画. 在线演示 源码下载 2, ...

  5. nginx配置多个网址

    实战Nginx与PHP(FastCGI)的安装.配置与优化:http://ixdba.blog.51cto.com/2895551/806622 Nginx配置文件详细说明:http://www.cn ...

  6. VC 2010下安装OpenCV2.4.4

    说明: 安装平台:32位XP,VS2010: OpenCV 2.4.4不支持VC 6.0: 网上有很多用CMake编译OpenCV的安装教程,这里建议先不要自己编译,如果使用预编译好的库有问题,再尝试 ...

  7. Git错误non-fast-forward后的冲突解决(转载)

    文章转载自:http://blog.csdn.net/chain2012/article/details/7476493 当要push代码到git时,出现提示: error:failed to pus ...

  8. Winform 拦截最小化、最大化、关闭事件【整理】

    const int WM_SYSCOMMAND = 0x112; //窗体关闭消息 const int SC_CLOSE = 0xf060; //窗体最小化消息 const int SC_MINIMI ...

  9. 【原】WinForm中的DataGridView加入Combbox或者DropDownButton后,操作变慢

    DataGridView里加入了DropDownButto列,加载数据后点击这一列,反应很慢;要点击三到四次才会展示下拉列表; 原因是DataGridView的EditMode设置问题; 将DataG ...

  10. Android之“Unfortunately,xxx has stopped!”

    初学Android遇到Unfortunately,xxx has stopped!真是一件让人头疼的事情,下面就遇到的两种可能情况给出解决方案.通常遇到的情况在于由一个Activity跳转至另一个Ac ...