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. Google Protocol Buffers学习

    参考资料:http://www.cnblogs.com/royenhome/archive/2010/10/29/1864860.html 参考资料:http://www.jianshu.com/p/ ...

  2. 【redis】1.redis-windows安装+配置介绍

    1.下载windows版本redis 官方下载地址:http://redis.io/download,不过官方没有64位的Windows下的可执行程序,目前有个开源的托管在github上, 地址:ht ...

  3. 容器技术|Docker三剑客之docker-compose

    三剑客简介 docker-machine docker技术是基于Linux内核的cgroup技术实现的,那么问题来了,在非Linux平台上是否就不能使用docker技术了呢?答案是可以的,不过显然需要 ...

  4. 使用模块PIL 生成 随机验证码

    --------------默认自己无能,无疑是给失败制造机会!你认为自己是什么样的人,就将成为什么样的人. 要使用PIL模块. 安装: 1 pip3 install pillow 基本使用 1. 创 ...

  5. redis 的使用,及如何使用redis维护数亿人的登录状态

    一.redis中几个常用的方法 redis的使用场景移步本文 select db redis 下默认有有16个表,0~15可以通过:select 2 或者 select 11这样的方式切换表 keys ...

  6. Vue之子组件

    全局组件 <script src="./static/vue.min.js"></script> // 导入vue <body> <div ...

  7. 解决ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

    解决办法:

  8. Vmware的虚拟机示例进入BIOS方法

    虚拟机(Vmware)怎么进入BIOS_百度经验 https://jingyan.baidu.com/article/7e440953e566472fc0e2eff7.html Vmware虚拟机进入 ...

  9. c++ 单引号"字符串" 用法

    __int64 flag; //赋值超过4字节,编译错误 //flag = 'ABCDE'; //低于4字节,高位补 0 //flag = 'BCDE'; flag = 'A' << 24 ...

  10. MySQL数据库性能优化思路与解决方法(二转)

    原文:http://bbs.landingbj.com/t-0-242512-1.html 1.锁定表 尽管事务是维护数据库完整性的一个非常好的方法,但却因为它的独占性,有时会影响数据库的性能,尤其是 ...