题目链接:

B. Inventory

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.

During an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.

You have been given information on current inventory numbers for n items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to n by changing the number of as few items as possible. Let us remind you that a set of n numbers forms a permutation if all the numbers are in the range from 1 to n, and no two numbers are equal.

Input

The first line contains a single integer n — the number of items (1 ≤ n ≤ 10^5).

The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 10^5) — the initial inventory numbers of the items.

Output

Print n numbers — the final inventory numbers of the items in the order they occur in the input. If there are multiple possible answers, you may print any of them.

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

In the first test the numeration is already a permutation, so there is no need to change anything.

In the second test there are two pairs of equal numbers, in each pair you need to replace one number.

In the third test you need to replace 2 by 1, as the numbering should start from one.

题意:

把n个数变成1到n这n个数输出,就是把原来重复的和大于n的去掉,补上1到n中没有出现过的;

思路:

水题,直接不想说;

AC代码:

/*2014300227    569B - 26    GNU C++11    Accepted    46 ms    1196 KB*/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+;
typedef long long ll;
const double PI=acos(-1.0);
int n,a[N],vis[N];
queue<int>qu;
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
vis[a[i]]++;
}
for(int i=;i<=n;i++)
{
if(!vis[i])qu.push(i);
}
for(int i=;i<=n;i++)
{
if(a[i]>n)printf("%d ",qu.front()),qu.pop();
else {
if(vis[a[i]]==)printf("%d ",a[i]);
else if(vis[a[i]]>)
{
printf("%d ",qu.front());
qu.pop();
vis[a[i]]--;
}
}
} return ;
}

codeforces 569B B. Inventory(水题)的更多相关文章

  1. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  2. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  3. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  4. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

  6. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  7. 【40.17%】【codeforces 569B】Inventory

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  9. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

随机推荐

  1. Android 中保存全局变量

    作者:silence鼬.2015年6月28日 在学习Android的时候一直未context的问题认为头疼,由于想做一些工具类,可是又不是四大组件.总要来回传递context.认为非常麻烦,就想全局获 ...

  2. ubuntu16.04 Cmake学习二

    本节主要总结编译程序的时候使用了第三方库的情况,以调用开源opencv-2.4.9为例子,具体安装详见http://www.cnblogs.com/xsfmg/p/5900420.html. 工程文件 ...

  3. php selenium 测试验证码问题

    $this->pause(10000)这段代码用于停止程序执行,可以在这个空隙内输入验证码

  4. HDFS源码分析心跳汇报之BPServiceActor工作线程运行流程

    在<HDFS源码分析心跳汇报之数据结构初始化>一文中,我们了解到HDFS心跳相关的BlockPoolManager.BPOfferService.BPServiceActor三者之间的关系 ...

  5. 简述什么是ajax、javascript、json、Jquery?

    什么是Javascript? 基于对象.解释型.事件驱动.脚本语言.封装在<script>标签中使用.弱类型.与浏览器交互执行 什么 是Ajax? ajax是一种编程模式.在客户端与服务器 ...

  6. 【虚拟机】WIN8.1系统虚拟机完全彻底删除

    一.首先删除注册表 用管理员身份打开CMD,输入F:\>VMware-workstation-full-12.5.5-5234757.exe/clean,根据自己的虚拟机安装文件的路径进行改变( ...

  7. Oracle exp使用正則表達式导出部分表

    假设数据库中有许多张表,而我们又仅仅想导出须要的那几张能够使用例如以下命令 --仅仅导出test1.test2表 exp myname/mypassword@orcl file = d:\my.dmp ...

  8. IdentityServer4 + SignalR Core +RabbitMQ 构建web即时通讯(三)

    IdentityServer4 + SignalR Core +RabbitMQ 构建web即时通讯(三) 后台服务用户与认证 新建一个空的.net core web项目Demo.Chat,端口配置为 ...

  9. 多文档自己主动文摘:Multi-Document Summarization,MDS

  10. wireshark 学习 3 display filter

    过滤信息,得到想要的帧进行分析. http://www.networkcomputing.com/networking/wifi-troubleshooting-using-wireshark/155 ...