题目链接:https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b?tpId=37&tags=&title=&diffculty=0&judgeStatus=0&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
int n;
int way;
string name;
int grade;
while(cin >> n >> way)
{
vector<string> b[101]; //0-100分的桶共101个
for(int i = 0; i < n; i++)
{
cin >> name >> grade;
b[grade].push_back(name);
}
if(way == 0)
{
for(int i = 100 ; i >= 0; i--)
{
for(int j = 0; j < b[i].size(); j++)
cout << b[i][j] << " " << i << endl;
}
}
else
{
for(int i = 0 ; i < 101; i++)
{
for(int j = 0; j < b[i].size(); j++)
cout << b[i][j] << " " << i << endl;
}
}
}
}