#include<iostream>
#include<algorithm> //醉了。。居然是字母排序的问题。。
using namespace std;
struct student{
int h;
string name;
}st[10010];
bool cmp(student a,student b){
if(a.h == b.h) return a.name<b.name;
return a.h>b.h;
}
int main(){
int n,k;
cin>>n>>k;
for(int i = 0;i<n;i++){
cin>>st[i].name>>st[i].h;
}
sort(st,st+n,cmp);
int count = 0; //记录学生序号
for(int i = 1;i<=k;i++){ //i为排数
int m = n/k;
if(i == 1) m += n%k;
int num = m-1; //记录起始编号
if(m%2==1) {
num -= 1;
}
while(num<m&&num>=0){
cout<<st[count+num].name<<" ";
num -= 2;
}
num += 1;
while(num<m&&num>=0){
cout<<st[count+num].name;
num += 2;
if(num<=m-1) cout<<" ";
}
count += m;
cout<<"\n";
}
return 0;
}
1055 集体照
最新推荐文章于 2025-02-18 16:52:55 发布
146

被折叠的 条评论
为什么被折叠?



