rq水题小练习赛后题解

· · 题解

rq水题小练习赛后题解

[rq排序小练习] 机房排名

相信大家已经看出来了,这道题只需要一个排序即可。
时间复杂度 O(n log n) 。
代码:(禁止抄袭,维护团队风气)

#include<bits/stdc++.h>
using namespace std;
int n,t,p[100005];
bool cmp(int A,int B){
    return A>B;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&p[i]);
    }
    sort(p+1,p+n+1,cmp);
    scanf("%d",&t);
    cout<<p[t];
}