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 ...
随机推荐
- python通过SMTP发送邮件失败,报错505/535
python通过SMTP发送邮件失败:错误1:smtplib.SMTPAuthenticationError: (550, b'User has no permission') 我们使用pyth ...
- UVa 496 Simply Subsets (STL&set_intersection)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=sh ...
- axf、elf文件转换成bin、hex脚本工具
在嵌入式开发过程中常常遇到将axf或elf文件转换成bin的情况,大家都知道通过gnu toolchain中的objcopy和keil中的fromelf能做到.可是为了这么一个小事而记住复杂的选项以及 ...
- [PWA] 11. Serve skeleton cache for root
Intead of cache the root floder, we want to cache skeleton instead. self.addEventListener('install', ...
- phpcms如何嵌套循环
PHPCMS V9的标签制作以灵活见长,可以自由DIY出个性的数据调用,对于制作有风格有创意的网站模板很好用,今天就介绍一个标签循环嵌套方法,可以实现对PC标签循环调用,代码如下: 在此文件里/php ...
- yii自动登陆的验证机制浅析
一直在使用yii进行开发, 也知道如何去使用, 也仅仅是知道怎么去用罢了, 终归是没研究过源码, 心里发虚, 今天遇到一个问题, 关于自动登陆的问题. 要求就是, 修改登陆保存session天数为自定 ...
- Python开发【第七篇】:面向对象 和 python面向对象进阶篇(下)
Python开发[第七篇]:面向对象 详见:<Python之路[第五篇]:面向对象及相关> python 面向对象(进阶篇) 上一篇<Python 面向对象(初级篇)> ...
- python函数的使用和返回值
#coding=utf-8 def a(): i=1a() #函数的返回值,用return语句实现 #一个返回值的情况def test(): i=7 return iprint test() #多个返 ...
- servlet+jdbc+javabean其实跟ssh差不多
我给的这个架构可以代替ssh的架构进行项目的开发 common中放的是一些公用类 dao中放的是一些对数据的处理 entity其实也就是javabean service中放的是一些抽象类,简单来说抽象 ...
- ViewPager 嵌套Listview 让Listview响应 ViewPager 左右滑事件
一段拦截判断而已. 之前一直误解了一个拦截的描述.导致搞了半天. 结论: onInterceptTouchEvent 返回true,就由本身View的onTouchEvent进行事件消费. /** ...