2 条题解

  • 0
    @ 2026-8-25 14:43:56

    #include <bits/stdc++.h>

    using namespace std;

    struct Student {

    int id;
    
    int score;
    

    };

    int main() {

    int n, k;
    
    cin >> n >> k;
    
    vector<Student> students(n);
    
    for (int i = 0; i < n; ++i) {
    
        cin >> students[i].id >> students[i].score;
        
    }
    
    sort(students.begin(), students.end(), [](const Student& a, const Student& b) {
    
        return a.score > b.score;
        
    });
    
    cout << students[k - 1].id << " " << students[k - 1].score << '\n';
    
    return 0;
    

    }

    信息

    ID
    177
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    2
    已通过
    2
    上传者