contest: Codeforces Round #307 (Div. 2), problem: (A) GukiZ and Contest

本文深入探讨了AI音视频处理领域中的视频分割与语义识别技术,介绍了视频分割的基本概念、算法及其应用,并详细阐述了语义识别在智能视频分析中的重要作用,包括其在自动驾驶、AR增强现实等场景中的实际应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. GukiZ and Contest
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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 BA 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.

Sample test(s)
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 3are the last sharing fourth position.


#include<cstdio>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
  
struct student {  
    int index,num;  //index-->rating,num-->下标  
}a[2000+10];  
  
int pos[2000+10];  //position  
  
bool cmp(student a,student b){  
return a.index>b.index;  
}  
  
int main(){  
int n;  
while(~scanf("%d",&n)){  
  for(int i=1;i<=n;i++)  
        scanf("%d",&a[i].index),a[i].num=i;  
  sort(a+1,a+n+1,cmp);  
  pos[a[1].num]=1;  
  int cnt=1,m=1;  
  for(int i=2;i<=n;i++){  
    if(a[i].index==a[i-1].index) pos[a[i].num]=m,cnt++;  
    else pos[a[i].num]=++cnt,m=cnt;  
  }  
  
  for(int i=1;i<n;i++)  
  printf("%d ",pos[i]);  
  printf("%d\n",pos[n]);  
}  
    return 0;  
}  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值