CF415AMashmokh and Lights(map)
2014-05-13 20:58
113 查看
题目链接:http://codeforces.com/problemset/problem/415/A
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main()
{
map<int ,int> p;
int n,m;
while(~scanf("%d%d",&n,&m))
{
int a;
p.clear();
while(m--)
{
cin>>a;
for(int i=a;i<=n;i++)
{
if(p[i]==0)
p[i]=a;
}
}
for(int i=1;i<=n;i++)
cout<<p[i]<<" ";
cout<<endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main()
{
map<int ,int> p;
int n,m;
while(~scanf("%d%d",&n,&m))
{
int a;
p.clear();
while(m--)
{
cin>>a;
for(int i=a;i<=n;i++)
{
if(p[i]==0)
p[i]=a;
}
}
for(int i=1;i<=n;i++)
cout<<p[i]<<" ";
cout<<endl;
}
return 0;
}
相关文章推荐
- JSF2.0实战 - 8、实现换肤功能
- AndroidUI组件之AlertDialog
- Linux内核学习第6天
- 第01章 数据结构与算法
- AsyncTask的使用 (二)图片下载,进度条
- javascript匿名函数的理解,js括号中括function 如(function(){})
- 在APACHE服务器上的访问方式上去除index.php
- WinForm中Timer倒计时
- Android:自定义控件
- 用国内软件源为Ubuntu的apt-get提速方法
- libgdx 仿微信打飞机完成版本(终结版)
- 多线程——AsyncTask类的使用(一)
- [译]What is the Web's Model of Computation?
- 百鸡问题
- vim中的缩进
- Chapter 4 的问题
- 第五届省赛总结
- Leetcode 树 Binary Tree Zigzag Level Order Traversal
- 获取iOS设备的内存状况
- 背包九讲(来源于Tianyi cui)