Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
49914 liuzhencong 谁考了第k名 C++ 通过 1 MS 256 KB 363 2024-07-31 16:22:11

Tests(1/1):


#include<bits/stdc++.h> using namespace std; struct stu{ int ID; float score; } a[1005]; int n, k;//人数、名次 bool cmp(stu x, stu y){ return x.score > y.score; } int main() { cin >> n >> k; for( int i=1;i<=n;i++) { cin>> a[i].ID >> a[i].score; } sort(a+1, a+n+1 , cmp); cout << a[k].ID <<" "<< a[k].score; return 0; }


测评信息: