Result: Accepted
Time: 3ms
Memory: 1120kB
#include<stdio.h>
struct student {
char name[21];
int time;
};
int main() {
struct student studentarray[101],x;
int t, i,n;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%s%d", &studentarray[i].name, &studentarray[i].time);
}
for (i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (studentarray[j].time < studentarray[j + 1].time) {
x = studentarray[j];
studentarray[j] = studentarray[j + 1];
studentarray[j+1] = x;
}
}
}
for (i = 0; i < n; i++) {
printf("%s\n", studentarray[i].name);
}
}
return 0;
}