题解
2023-08-16 20:52:25
发布于:广东
13阅读
0回复
0点赞
话不多说,请看题解~
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Volunteer {
int id;
int score;
};
bool compare(Volunteer a, Volunteer b) {
if (a.score == b.score) {
return a.id < b.id;
}
return a.score > b.score;
}
int main() {
int n, m;
cin >> n >> m;
vector<Volunteer> volunteers(n);
for (int i = 0; i < n; i++) {
cin >> volunteers[i].id >> volunteers[i].score;
}
sort(volunteers.begin(), volunteers.end(), compare);
int cutoff = volunteers[(m-1)*3/2].score;
int count = 0;
for (Volunteer v : volunteers) {
if (v.score >= cutoff) {
count++;
} else {
break;
}
}
cout << cutoff << " " << count << endl;
for (int i = 0; i < count; i++) {
cout << volunteers[i].id << " " << volunteers[i].score << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个