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 ...
随机推荐
- Java 日志缓存机制的实现--转载
概述 日志技术为产品的质量和服务提供了重要的支撑.JDK 在 1.4 版本以后加入了日志机制,为 Java 开发人员提供了便利.但这种日志机制是基于静态日志级别的,也就是在程序运行前就需设定下来要打印 ...
- 有向图的欧拉路径POJ2337
每个单词可以看做一条边,每个字母就是顶点. 有向图欧拉回路的判定,首先判断入度和出度,其实这个题判定的是欧拉通路,不一定非得构成环,所以可以有一个点的顶点入度比出度大1,另外一个点的出度比入度大1,或 ...
- PHP 网页爬虫
只能爬一个页面 <?php function get_urls($url){ $url_array=array(); $the_first_content=file_get_contents($ ...
- linux common command.
Stopping & Starting shutdown -h now – Shutdown the system now and do not reboothalt – Stop all p ...
- web.xml配置详解 (及<context-param>配置作用 )
http://blog.csdn.net/guihaijinfen/article/details/8363839 <context-param>配置作用 http://blog.csdn ...
- cursor 与refcursor及sys_refcursor的区别 (转载)
楼主标明是转载的,我只把我转载的地址发上来 http://www.cnblogs.com/honliv/archive/2011/07/21/2112639.html 显式是相对与隐式cursor而言 ...
- Swift - 31 - 常量参数, 变量参数和inout参数
//: Playground - noun: a place where people can play import UIKit // swift中默认情况下, 传入的参数是不可以修改的, 也就是l ...
- [转载]C++中 引用&与取地址&的区别
一个是用来传值的 一个是用来获取首地址的 &(引用)==>出现在变量声明语句中位于变量左边时,表示声明的是引用. 例如: int &rf; // 声明一个int型的引用r ...
- mktime性能问题
#include <time.h> int main() { for (int i = 0; i < 100000; ++i) { struct tm tm = {}; tm.tm_ ...
- 在ubuntu14.04上安装oracle java6 java7的方法
注意: Debian建议安装openjdk,在release包中已包含. oracle的java需要自己安装,安装步骤如下: 1. 首先安装java-package,安装方法:apt-get inst ...