Codeforces Round #307 (Div. 2) A. GukiZ and Contest 水题
A. GukiZ and Contest
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/551/problem/A
Description
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 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.
Sample Input
3
1 3 3
Sample Output
3 1 1
HINT
题意
给这n个学生排名
题解:
排个序,撸一遍就好了
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** struct node
{
int x,y;
};
bool cmp(node a,node b)
{
return a.x>b.x;
}
node a[maxn];
int b[maxn];
int main()
{
int n=read();
for(int i=;i<=n;i++)
a[i].x=read(),a[i].y=i;
sort(a+,a++n,cmp);
int last=-inf;
int ans=;
for(int i=;i<=n;i++)
{
if(last!=a[i].x)
{
ans=i;
last=a[i].x;
}
b[a[i].y]=ans;
}
for(int i=;i<=n;i++)
cout<<b[i]<<" ";
}
Codeforces Round #307 (Div. 2) A. GukiZ and Contest 水题的更多相关文章
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
- Codeforces Round #357 (Div. 2) A. A Good Contest 水题
A. A Good Contest 题目连接: http://www.codeforces.com/contest/681/problem/A Description Codeforces user' ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- 浏览器的DNS缓存
通过设置hosts文件可以强制指定域名对应的IP,当修改hosts文件,想要浏览器生效,最直接的方法关闭浏览器后重新开启:如果不想重启浏览器,只需要清空浏览器的DNS缓存即可.清空DNS缓存在chro ...
- Delphi 7使用自定义图标关联文件类型
Delphi 7使用自定义图标关联文件类型 5.2 Delphi编程(40) 版权声明:本文为博主原创文章,未经博主允许不得转载. 在开发过程中,我们经常需要属于自己的文件类型,自定义的后缀名不仅可 ...
- 部署WAR文件到tomcat
1.启动tomcat服务 2.在浏览器的地址栏输入地址“http://localhost:8080/manager/html”进入tomcat管理界面. 如果要管理的服务器是在网络中,则将localh ...
- linux_2015_0827_linux中一些常用词的发音and…
linux相关 Unix: [ ju:niks ] 发音 (yew-nicks) 尤里克斯 GNU [ gəˈnju: ] 发音 (guh-noo) 葛扭 Linux: [ 'li:nэks ] 里那 ...
- python中的文件
Python文件 1. 概述 文件对象不仅可以用来访问普通的磁盘文件,也可以访问任何其他类型抽象层面上的文件. 内建函数open()以及file()提供了初始化输入输出(I/O)操作的通用接口. ...
- iOS 获取通讯录权限的时机
建议将获取通讯录权限的代码放到 -(void)viewDidAppear:(BOOL)animated 或 -(void)viewWillAppear:(BOOL)animated 假如放在 view ...
- 【转】 ASP.NET网站路径中~(波浪线)解释
刚开始学习ASP.NET的朋友可能会不理解路径中的-符代表什么,例如ImageUrl=”~/Images/SampleImage.jpg” 现在我们看看-代表什么意思.-是ASP.NET 的Web 应 ...
- Spark RDD概念学习系列之RDD是什么?(四)
RDD是什么? 通俗地理解,RDD可以被抽象地理解为一个大的数组(Array),但是这个数组是分布在集群上的.详细见 Spark的数据存储 Spark的核心数据模型是RDD,但RDD是个抽象类 ...
- 导出Excel Gridview
/// <summary> /// 定义导出Excel的函数 /// </summary> /// <param name="FileType ...
- 通过ModuleImplAdvertisement向自定义服务传递参数
无意中发现通过ModuleImplAdvertisement可以向自定义服务传递参数,有空试一试. —————————————————————————————————————————————————— ...