题解 | #小白鼠排队#
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10; struct Rat { int m; string color; } rats[N]; bool cmp(Rat r1, Rat r2) { return r1.m > r2.m; } int main(void) { int n; while (cin >> n) { for (int i = 0; i < n; i++) { cin >> rats[i].m >> rats[i].color; } sort(rats, rats + n, cmp); for (int i = 0; i < n; i++) { cout << rats[i].color << endl; } } return 0; }