New Year Ratings Change

CodeForces - 379C

One very well-known internet resource site (let's call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to all visitors.

There are n users on the site, for each user we know the rating value he wants to get as a New Year Present. We know that user i wants to get at least ai rating units as a present.

The X site is administered by very creative and thrifty people. On the one hand, they want to give distinct ratings and on the other hand, the total sum of the ratings in the present must be as small as possible.

Help site X cope with the challenging task of rating distribution. Find the optimal distribution.

Input

The first line contains integer n (1 ≤ n ≤ 3·105) — the number of users on the site. The next line contains integer sequence a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print a sequence of integers b1, b2, ..., bn. Number bi means that user i gets bi of rating as a present. The printed sequence must meet the problem conditions.

If there are multiple optimal solutions, print any of them.

Examples

Input
3
5 1 1
Output
5 1 2
Input
1
1000000000
Output
1000000000

sol:XJB乱构造即可,每次要么是ai,否则就是上一个加1
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,ans[N];
struct Record
{
int Num,Id;
inline bool operator<(const Record &tmp)const
{
return Num<tmp.Num;
}
}a[N];
int main()
{
int i,Now=;
R(n);
for(i=;i<=n;i++) R(a[a[i].Id=i].Num);
sort(a+,a+n+);
for(i=;i<=n;i++)
{
ans[a[i].Id]=max(Now,a[i].Num);
Now=max(Now+,a[i].Num+);
}
for(i=;i<=n;i++) W(ans[i]);
return ;
}
/*
Input
3
5 1 1
Output
5 1 2 Input
1
1000000000
Output
1000000000
*/
 

codeforces379C的更多相关文章

随机推荐

  1. apt查找安装包

    1.查找名称含openblas的安装包 apt-cache search openblas

  2. 基于注解处理器开发自动生成getter和setter方法的插件

    昨天无意中,逛到了lombok的网站,并看到了首页的5分钟视频,视频中的作者只是在实体类中写了几个字段,就可以自动编译为含setter.getter.toString()等方法的class文件.看着挺 ...

  3. MiniProfiler安装使用心得

    MiniProfiler简介: MVC MiniProfiler是Stack Overflow团队设计的一款对ASP.NET MVC的性能分析的小程序.可以对一个页面本身,及该页面通过直接引用.Aja ...

  4. 【React】开发一个城市选择控件

    想到做这个,是因为无意中在github上看到了这一个仓库https://github.com/lunlunshiwo/ChooseCity,做的就是一个城市选择控件,是用vue写的,说的是阿里的一道题 ...

  5. 修改docker0默认IP地址

    第一步:vim /etc/docker/daemon.json { "registry-mirrors": ["https://docker.mirrors.ustc.e ...

  6. python全栈开发慕课网

    前端 web框架: flask:简单.轻量.灵活性大 (官网,stck overflowa); 目录结构:配置,发布,资源,日志,测试... 前后端协作:整体发布,前后端分离发布 django:简单, ...

  7. 使用 Markdown编辑

    作用: 学习笔记,整理日志, 发布日记,杂文,所见所想 撰写发布技术文稿(代码支持) 撰写发布学术论文(LaTeX 公式支持) sublime text3插件 输入 Shift + Ctrl + P, ...

  8. 动态规划-LCS最长公共子序列

    #include<iostream> #include<cstdio> #include<cstring> #include<string> using ...

  9. JavaScript中的各种X,Y,Width,Height

    在JavaScript DOM编程中,会接触很多很多很多关于浏览器的宽高,屏幕的宽高,元素的各种宽高,以及鼠标的坐标等,常常让人搞混.索性就写篇博客整理一下. case 1:鼠标的坐标 获取鼠标的坐标 ...

  10. Java Core - 序列化和反序列化

    把对象转换为字节序列的过程称为对象的序列化 把字节序列恢复成对象的过程称为对象的反序列化 一.对象的序列化的应用: 1.把对象的字节序列永久地保存到硬盘上,通常存放在一个文件中. 2.在网络上传送对象 ...