cf C. New Year Ratings Change
http://codeforces.com/contest/379/problem/C
思路:先排序,然后判断如果rating>ans,ans=rating否则ans++;然后对应的位置输出就可以;
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#define LL __int64
#define maxn 500010
using namespace std;
int t;
int n;
LL a[maxn];
LL b[maxn];
struct node
{
LL x;
LL id;
bool operator <(const node &a)const
{
return x<a.x;
}
}p[maxn]; int main()
{
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%I64d",&a[i]);
p[i].x=a[i];
p[i].id=i;
}
sort(p,p+n);
int ans;
ans=b[p[].id]=p[].x;
for(int i=; i<n; i++)
{
if(p[i].x>ans)
{
ans=p[i].x;
b[p[i].id]=ans;
}
else
{
ans++;
b[p[i].id]=ans;
}
}
for(int i=; i<n; i++)
{
if(i==)
printf("%I64d",b[i]);
else
printf(" %I64d",b[i]);
}
printf("\n");
return ;
}
cf C. New Year Ratings Change的更多相关文章
- codeforces C. New Year Ratings Change 解题报告
题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...
- CF379C-New Year Ratings Change
https://www.luogu.org/problemnew/show/CF379C 一道水题,折腾了我好久! 解题: 先排序,从小到大挨个满足客户,把最终rating放进集合里,判断是否已经给出 ...
- Java和PHP哪个方向更有前途?
Java和PHP到底哪个方向更有前途呢?我从网络上收集了很多资料,并在这篇文章中做了总结. 1.TIOBE语言排行榜 Apr 2014 Apr 2013 Change Programming ...
- TIOBE Index for January 2016(转载)
Java has won the TIOBE Index programming language award of the year. This is because Java has the la ...
- TIOBE Index for December 2015(转载)
There is hardly any doubt about it, Java will become TIOBE's programming language of the year 2015. ...
- TIOBE Index for November 2015(转载)
原文地址:http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html November Headline: Java once a ...
- Good Bye 2013 C
C. New Year Ratings Change time limit per test 1 second memory limit per test 256 megabytes input st ...
- Linux 安装rar解压工具
下载RAR安装包: http://www.rarsoft.com/download.htm 我的是CentOS 64位: wget http://www.rarsoft.com/rar/rarlinu ...
- TIOBE.2017.01最新编程语言排行榜
Jan 2017 Jan 2016 Change Programming Language Ratings Change1 1 Java ...
随机推荐
- Android的adb命令使用以及在DOS的一系列操作
adb是什么?:adb的全称为Android Debug Bridge,就是起到调试桥的作用. adb有什么用?:借助adb工具,我们可以管理设备或手机模拟器的状态.还可以进行很多手机操作, ...
- gradle 集成到myeclipse
新的项目用到gradle,所以学了下,地址:http://dist.springsource.com/release/TOOLS/gradle :help 下,安装好,重启即可,gradle作为mav ...
- ECLIPSE里面SVN图标消失,文件状态不显示问题
ECLIPSE里面SVN状态图标消失,重新启动eclipse,重新导入工程也不能显示SVN状态图标.这多半是由于之前eclipse没有正常关闭引起的. 解决办法2个: 方法一:1. 在Window&g ...
- [Unity3d][NGUI]两种思路解决AssetBundle的依赖关系.
接上文. 使用上文中的AssetBundle打包方式生成的文件包括了依赖关系中的文件. 一般的使用中并不会发现什么问题. 可是当配合NGUI的时候,使用dynamicFont时打包AssetBundl ...
- VC6项目移植到VS2008的若干问题——好的代码,从我做起,从如今做起。
近期,有个项目开发,须要用到曾经项目的代码,只是曾经项目都是VC6下编译通过的,在VS2008下不一定编译通过,能编译通过也不一定能链接成功.以下总结一下我在一个VC6项目移植到VS2008中遇到的一 ...
- [Angular 2] Using ng-model for two-way binding
Two-way binding still exists in Angular 2 and ng-model makes it simple. The syntax is a combination ...
- HDU-1053-Entropy(Huffman编码)
Problem Description An entropy encoder is a data encoding method that achieves lossless data compres ...
- [转] Java中继承thread类与实现Runnable接口的区别
Java中线程的创建有两种方式: 1. 通过继承Thread类,重写Thread的run()方法,将线程运行的逻辑放在其中 2. 通过实现Runnable接口,实例化Thread类 在实际应用中, ...
- 解决Ubuntu 14.04 下SMPlayer的字幕乱码问题
1.SMPlayer播放器 对于使用ubuntu系统的同学,虽然系统初始就带有vedio播放器,但是这里强烈推荐SMPlayer,直接在Ubuntu Software Center中就可以免费下载安装 ...
- SpringMVC10数据验证
/** * @NotBlank 作用在String * @NotEmpty 作用在集合上 * @NotNull 作用在基本数据类型上 * */ public class User { @NotNull ...