P1068 [NOIP2009 普及组] 分数线划定
作者:互联网
// Problem: P1068 [NOIP2009 普及组] 分数线划定
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1068
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn
#include <bits/stdc++.h>
using namespace std;
struct Candidate {
int id;
int score;
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<Candidate> info(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> info[i].id >> info[i].score;
}
sort(info.begin() + 1, info.end(), [](const Candidate &c1, const Candidate &c2) -> bool {
if (c1.score != c2.score) {
return c1.score > c2.score;
} else {
return c1.id < c2.id;
}
});
int line = info[(int)(m * 1.5)].score;
vector<Candidate> res;
for (int i = 1; i <= n; ++i) {
if (info[i].score >= line) {
res.push_back(info[i]);
}
}
cout << line << " " << res.size() << endl;
for(int i = 0; i < res.size(); ++i) {
cout << res[i].id << " " << res[i].score << endl;
}
return 0;
}
标签:info,int,NOIP2009,id,P1068,score,c2,分数线,c1 来源: https://www.cnblogs.com/pannnn/p/15855085.html