【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个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...
随机推荐
- C++ 与C# 对应的变量互转
一.C++ 与C# 对应的变量互转的使用实例 C++的动态链接库的函数: C# 调用C++动态链接库数据类型的转换,其中在C++中数据类型为char *,在C#中对应的数据类型为intPtr. 二.常 ...
- 【习题 7-1 UVA-208】Firetruck
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 预处理一下终点能到达哪些点. 暴力就好. 输出结果的时候,数字之间一个空格.. [代码] /* 1.Shoud it use lon ...
- KNIMI数据挖掘建模与分析系列_002_利用KNIMI做商超零售关联推荐
利用KNIMI做商超零售关联推荐 http://blog.csdn.net/shuaihj 一.測试数据 须要測试数据,请留下邮箱 二.训练关联推荐规则 1.读取销售记录(sales.table) 2 ...
- JQuery源码解析 目录
1. a.$查询符号就是放在沙盒里面的: window.jQuery = window.$ = jQuery; b.一个jQuery对象无 new 构造: eg: $("#text" ...
- VC++的函数指针和回调函数 及友元函数
什么是函数指针 函数指针是指向函数的指针变量.也就是说,它是一个指针变量,而且该指针指向一个函数. 对于指针变量来说,它的值是它指向的变量的地址.举个例子:指针变量pi是指向一个整型变量i的指针,则变 ...
- tomcat的classloader机制
本系列博客打算分析一下tomcat7.x的源码,其中可能会穿插一些java基础知识的介绍 读tomcat的源码的时候,我建议和官方的User Guide一起阅读,明白tomcat做某件事情的目的之后 ...
- JS学习笔记 - fgm练习 2-11- 改变图片路径 var img = new Image(); 图片预加载
<style> *{ margin: 0;padding: 0; list-style: none; } body{ background: black; } .outer{ margin ...
- var let 区别
var a = 5; var b = 10; if (a === 5) { let a = 4; // if 块级作用域 var b = 1; // 函数级作用域 console.log(a); // ...
- DC针对pipeline的优化
set_optimize_register true compile -ultra 调整pipleline各级的组合逻辑,使得各级组合逻辑的延迟跟接近 对非pipeline进行优化: regi ...
- 卫星网络中使用TCP协议的劣势(所以才有TCP优化版用来卫星通信啊,比如TCP-Peach和ADolar)
卫星网络中使用TCP协议的劣势 为了避免产生网络拥塞,原TCP协议综合采用了慢启动.拥塞避免.快速重传以及快速恢复等算法.但这些算法应用的前提是网络发生拥塞造成丢包,然而在误码率相对较高的卫星通信系统 ...