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. python:unittest之跳过测试和预期失败的用例

    在利用单元测试框架执行测试用例的过程中,有时只需要执行一部分用例,或者跳过某些暂不需要执行的用例,python的unittest框架就内置这样的功能. 前面的博客介绍了unittest框架的测试用例加 ...

  2. P1337 [JSOI2004]平衡点 / 吊打XXX

    题目描述 如图:有n个重物,每个重物系在一条足够长的绳子上.每条绳子自上而下穿过桌面上的洞,然后系在一起.图中X处就是公共的绳结.假设绳子是完全弹性的(不会造成能量损失),桌子足够高(因而重物不会垂到 ...

  3. Tomcat优化之容易集合经验

    Tomcat优化1. 如何加大tomcat连接数在tomcat配置文件server.xml中的<Connector ... />配置中,和连接数相关的参数有: maxThreads : t ...

  4. flink1.7 checkpoint源码分析

    初始化state类 //org.apache.flink.streaming.runtime.tasks.StreamTask#initializeState initializeState(); p ...

  5. [原创]Sharding-Sphere之Proxy初探

    大家好,拓海(https://github.com/tuohai666)今天为大家分享Sharding-Sphere推出的重磅产品:Sharding-Proxy!在之前闪亮登场的Sharding-Sp ...

  6. flask使用基础

    1.安装 pip install Flask 基本依赖库: jinja2:实现对模板的处理 werkzeug:本质是socket服务器,用于接收http请求,并对请求进行预处理,然后触发Flaks框架 ...

  7. Python_迭代器-生成器-复习-习题_41

    # 迭代器和生成器# 迭代器 # 可迭代协议 —— 含有iter方法的都是可迭代的 # 迭代器协议 —— 含有next和iter的都是迭代器 # 特点 # 节省内存空间 # 方便逐个取值,一个迭代器只 ...

  8. plw的骰子

    链接 [http://murphyc.fun/problem/4007] 题意 描述 duxing2016有一个神奇的骰子,投出1-6的概率为(p1,p2...p6) 现在他投n次骰子,问投出点数和大 ...

  9. python文件读和写

    fileHandle = open ( 'G:/qqfile/1.txt','w' )fileHandle.write('abcd')#写文件 地址要用反斜杠fileHandle.close() fi ...

  10. vue 使用sass 和less

    npm i sass-loader --save -dev(-D)