|
|
back to boardTest 11 - Time limit exceed Posted by Henker 12 Nov 2014 14:36 #include <stdio.h> #include <stdlib.h> struct Team { int id; int m; }; int main() { int n; struct Team * res;
scanf ("%d", &n); res = (struct Team*)malloc( n * sizeof(struct Team) );
for (int i = 0; i < n; i++) scanf ("%d %d", &res[i].id, &res[i].m); struct Team tmp; for (int i = 0; i < n-1; i++) for (int j = 0; j < n-1; j++) if (res[j].m < res[ j+1 ].m) { tmp = res[j]; res[j] = res[ j+1 ]; res[ j+1 ] = tmp; } for (int i = 0; i < n; i++) printf ("%d %d\n", res[i].id, res[i].m); return 0; } |
|
|