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 ...
随机推荐
- ganglia Web前端清除当机节点
ganglia默认如果服务器down机也不会在web前段清除该设备,官方文档介绍的办法如下: 1. 登录中央gmeta和gmond机器 2. vi gmond.conf,修改如下,host_dmax默 ...
- Linux 和 Windows 下对long long的输出
以前一直用__int64来识别windows还是Linux,可是发现HDU好像不认 看到wzy用的UNIX可以. UNIX是Linux下定义的,具体是什么可以去百度. 那么就可以 #ifdef UNI ...
- 详细分析 javascript 的内存分配
JavaScript语言是一门优秀的脚本语言.其中包含脚本语言的灵活性外还拥有许多高级语言的特性.例如充许构建和实例化一个对象,垃圾回 收机制(GC:Garbage Collecation).通常我们 ...
- android 自定义Toast显示风格
1.创建一个自己想要显示Toast风格的XML如下代码(toast_xml.xml): <?xml version="1.0" encoding="utf-8&qu ...
- 2015湖南省选集训DAY5——work(BZOJ4177)
Description Mike有一个农场,这个农场n个牲畜围栏,如今他想在每一个牲畜围栏中养一仅仅动物,每仅仅动物能够是牛或羊,并且每一个牲畜围栏中的饲养条件都不同,当中第i个牲畜围栏中的动物长大后 ...
- HeadFirst设计模式笔记:(六)命令模式 —— 封装调用
1.概念 将来自客户端的请求传入一个对象,从而使你可用不同的请求对客户进行参数化.用于“行为请求者”与“行为实现者”解耦,可实现二者之间的松耦合,以便适应变化.分离变化与不变的因素. 在面向对象的程序 ...
- Change value of string array at debug eclipse--转
Question: I have an application, but to test something, I need to change value of a String[]. But wh ...
- 用Wget进行下载
wget下载可以不用考虑资源的双向认证的问题,即 wget -N -S -O " + filePath + " " + urlStr + " --no-chec ...
- 调试exynos4412—ARM嵌入式Linux—LEDS/GPIO驱动之三
/** ****************************************************************************** * @author 暴走的小 ...
- 中国剩余定理模板poj1006
#include <cstdio> #include <iostream> #include <cstring> #include <cmath> #i ...