题目 

#include<iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;
struct ss {
	string name;
	int h;
};
bool cmp(struct ss a,struct ss b) {
	if(a.h==b.h)
		return a.name < b.name;
	else
		return a.h>b.h;
}
int main() {
	int n,k;
	cin>>n>>k;
	int m;
	struct ss s[n];
	for(int i=0; i<n; ++i)
		cin>>s[i].name>>s[i].h;
	sort(s,s+n,cmp);
	int l=0,r=k;
	for(int j=k-1; j>=0; --j) {
		if(j==k-1) {
			m=n-n/k*(k-1);
		} else m=n/k;
		string ans[m];
		int t=m/2;
		ans[t]=s[l].name;
		int c=t-1;
		for(int i=l+1; i<l+m; i+=2)
			ans[c--]=s[i].name;
		c=t+1;
		for(int i=l+2; i<m+l; i+=2)
			ans[c++]=s[i].name;
		cout<<ans[0];
		for(int i=1; i<m; ++i)
			cout<<" "<<ans[i];
		cout<<endl;
		l+=m;
	}
	return 0;
}