【74.89%】【codeforces 551A】GukiZ and Contest
time limit per test2 seconds 
memory limit per test256 megabytes 
inputstandard input 
outputstandard output 
Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.
In total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to n. Let’s denote the rating of i-th student as ai. After the contest ends, every student will end up with some positive integer position. GukiZ expects that his students will take places according to their ratings.
He thinks that each student will take place equal to . In particular, if student A has rating strictly lower then student B, A will get the strictly better position than B, and if two students have equal ratings, they will share the same position.
GukiZ would like you to reconstruct the results by following his expectations. Help him and determine the position after the end of the contest for each of his students if everything goes as expected.
Input 
The first line contains integer n (1 ≤ n ≤ 2000), number of GukiZ’s students.
The second line contains n numbers a1, a2, … an (1 ≤ ai ≤ 2000) where ai is the rating of i-th student (1 ≤ i ≤ n).
Output 
In a single line, print the position after the end of the contest for each of n students in the same order as they appear in the input.
Examples 
input 
3 
1 3 3 
output 
3 1 1 
input 
1 
1 
output 
1 
input 
5 
3 5 3 4 5 
output 
4 1 4 3 1 
Note 
In the first sample, students 2 and 3 are positioned first (there is no other student with higher rating), and student 1 is positioned third since there are two students with higher rating.
In the second sample, first student is the only one on the contest.
In the third sample, students 2 and 5 share the first position with highest rating, student 4 is next with third position, and students 1 and 3 are the last sharing fourth position.
【题目链接】:http://codeforces.com/contest/551/problem/A
【题解】 
 
模拟 
模拟它的要求排序就好了. 
用结构体比较方便。 
 
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int MAXN = 2000+100;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
struct abc
{
    int x,pos;
};
int n;
abc a[MAXN];
int ans[MAXN];
bool cmp(abc a,abc b)
{
    return a.x < b.x;
}
int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    scanf("%d",&n);
    rep1(i,1,n)
        rei(a[i].x),a[i].pos = i;
    sort(a+1,a+1+n,cmp);
    rep1(i,1,n)
    {
        int l = i,r = i;
        while (r+1<=n && a[r+1].x == a[l].x)
            r++;
        int temp = n-r+1;
        rep1(j,l,r)
            ans[a[j].pos] = temp;
    }
    rep1(i,1,n)
        {
            printf("%d",ans[i]);
            if (i==n)
                puts("");
            else
                putchar(' ');
        }
    return 0;
}
【74.89%】【codeforces 551A】GukiZ and Contest的更多相关文章
- 【 BowWow and the Timetable CodeForces - 1204A 】【思维】
		
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...
 - 【29.89%】【codeforces 734D】Anton and Chess
		
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
 - 【32.89%】【codeforces 574D】Bear and Blocks
		
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
 - 【74.00%】【codeforces 747A】Display Size
		
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
 - 【codeforces 757D】Felicity's Big Secret Revealed
		
[题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...
 - 【codeforces 415D】Mashmokh and ACM(普通dp)
		
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
 - 【搜索】【并查集】Codeforces 691D Swaps in Permutation
		
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
 - 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
		
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
 - 【链表】【模拟】Codeforces 706E Working routine
		
题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...
 
随机推荐
- BZOJ2118: 墨墨的等式(最短路构造/同余最短路)
			
Description 墨墨突然对等式很感兴趣,他正在研究a1x1+a2y2+…+anxn=B存在非负整数解的条件,他要求你编写一个程序,给定N.{an}.以及B的取值范围,求出有多少B可以使等式存在 ...
 - HDU4630-No Pain No Game(离线,线段树)
			
Problem Description Life is a game,and you lose it,so you suicide. But you can not kill yourself bef ...
 - 程序猿必须知道FTP命令
			
程序猿必须知道FTP命令 文件传输软件的使用格式为:FTP<FTP地址>.若连 接成功.系统将提示用户输入 ...
 - 13.Zookeeper的java客户端API使用方法
			
转自:https://blog.csdn.net/jiuqiyuliang/article/details/56012027
 - cookie记住用户名密码
			
<script src="js/jquery.cookie.js" type="text/javascript"></script> $ ...
 - (入门整理学习一)Asp.net core
			
1.安装.net code SDK,vs Code;vs code c#插件可在软件扩展 (我网盘有) vs2015上安装教程:http://www.cnblogs.com/wangrudong00 ...
 - UVA - 590Always on the run(递推)
			
题目:UVA - 590Always on the run(递推) 题目大意:有一个小偷如今在计划着逃跑的路线,可是又想省机票费. 他刚開始在城市1,必须K天都在这N个城市里跑来跑去.最后一天达到城市 ...
 - JPA学习笔记(11)——使用二级缓存
			
一级缓存 查询两次id为1的user User user1 = entityManager.find(User.class, 1); User user2 = entityManager.find(U ...
 - docker中发布springboot
			
http://note.youdao.com/noteshare?id=81a603b1b33731aaef7b7755c70f33fb
 - 【例题 4-1 UVA - 1339】 Ancient Cipher
			
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 位置其实都没关系了. 只要每个字母都有对应的字母,它们的数量相同就可以了. 求出每种字母的数量. 排序之后. 肯定是要一一对应的. ...