题解 | #[NOIP2009]分数线划定#
[NOIP2009]分数线划定
https://ac.nowcoder.com/acm/problem/16625
using namespace std;
int n,m;
struct people{
int k;
int s;
}peo[5010];
bool cmp(people &p1 , people &p2){
if(p1.s == p2.s){
return p1.k < p2.k;
}
return p1.s>p2.s;
}
int main(){
while(cin>>n>>m){
for(int i = 1 ; i<=n+1 ;++i){
cin>>peo[i].k>>peo[i].s;
}
sort(peo+1,peo+1+n,cmp);
int index = floor(m*1.5);
int score = peo[index].s;
while (peo[index].s == peo[index+1].s){
index++;
}
printf("%d %d\n",score,index);
for(int i =1 ; i<=index ;++i){
printf("%d %d\n",peo[i].k,peo[i].s);
}
}
}