codeforces379C
New Year Ratings Change
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
3
5 1 1
5 1 2
1
1000000000
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的更多相关文章
随机推荐
- python:unittest之discover()方法批量执行用例
自动化测试过程中,自动化覆盖的功能点和对应测试用例之间的关系基本都是1 VS N,如果每次将测试用例一个个单独执行,不仅效率很低, 无法快速反馈测试结果,而且维护起来很麻烦.在python的单元测试框 ...
- 使用sql语句比较excel中数据的不同
使用sql语句比较excel中数据的不同 我所在的项目组是一套物流系统,负责与公司的电商系统进行对接.但是公司的电商系统的省市区的配置和物流系统的省市区的配置有差异,所以需要找到这些差异. 首先找到我 ...
- C#代码中插入X86汇编
这两天在看C# SIMD相关的东西, 在爆栈上面搜到一段代码, 表示很震惊, 还是得贴出来… [UnmanagedFunctionPointer(CallingConvention.StdCall)] ...
- (Beta)Let's-版本测试报告
测试中发现的Bug Version 2.0 Bug List 在无活动的活动列表下拉加载会崩溃 不能更改个人头像 用户和活动不显示头像 百度地图无法打开 在某些机型上软件装不上 图片加载有时不加载,有 ...
- ElasticSearch 分组查询的几个例子
facets接口可以根据query返回统计数据,其中的 terms_stats 是分组统计,根据key的情况返回value的统计数据,类似group by的意思. "terms_stats& ...
- 中国科学技术大学统一身份认证系统CAS
CAS | Apereohttps://www.apereo.org/projects/cas 中国科学技术大学统一身份认证系统https://passport.ustc.edu.cn/login?s ...
- Python技术之书籍汇总
近日,一直在学习Python,发现有关的书籍还是很多值得一读的,所以在此总结一下.以后慢慢去研读吧!!! Python入门 <Python编程快速上手——让繁琐工作自动化> 作者: [美] ...
- MYSQL 表大小限制
MySQL 3.22限制的表大小为4GB.由于在MySQL 3.23中使用了MyISAM存储引擎,最大表尺寸增加到了65536TB(2567 – 1字节).由于允许的表尺寸更大,MySQL数据库的最大 ...
- C#复习笔记(3)--C#2:解决C#1的问题(实现迭代器的捷径)
实现迭代器的捷径 从这个题目上可以看到C#1实现一个迭代器模式的话是多么的痛苦,我自己也写过不下40行的代码来实现一个迭代器,C#中的迭代器模式是通过IEnumerable和他的泛型等价物IEnume ...
- asp.net core发布到linux
在发布到linux的过程中出现两个问题现在总结一下: 我的虚拟机是安装到本机上面的,所以,应该在虚拟机的设置里面设置端口映射.具体设置如下: 选择vm上方的编辑 在弹出的框中选择VMnet8,点击下方 ...