#include #include #include

using namespace std; struct Student { int number;//学号 int score;//成绩 }; const int MAX = 100; Student stu[MAX];

bool compare(Student x, Student y) { if (x.score == y.score) { return y.number > x.number; } else { return x.score < y.score; } }

int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d%d", &stu[i].number,&stu[i].score); } sort(stu, stu+n, compare); for (int j = 0; j < n; j++) { printf("%d %d", stu[j].number, stu[j].score); printf("\n"); } return 0; }