CodeforcesRound#240(Div.2)_html/css_WEB-ITnose
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CodeforcesRound#240(Div.2)_html/css_WEB-ITnose,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含10879字,纯文字阅读大概需要16分钟。
内容图文
500pt:
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.
Sample test(s)
input
5 44 3 1 2
output
1 1 3 4 4
input
5 55 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.
分析:弄一个数组,开始初始化为-1,然后每次开关某light,就把比它大的还是-1的值设为该开关
代码:
#include #include #include
内容总结
以上是互联网集市为您收集整理的CodeforcesRound#240(Div.2)_html/css_WEB-ITnose全部内容,希望文章能够帮你解决CodeforcesRound#240(Div.2)_html/css_WEB-ITnose所遇到的程序开发问题。
如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
来源:【匿名】