#include #include #include #include #include #include int main() { long N; scanf("%ld", &N); char **C = (char**) malloc(N * sizeof(char*)); long *score = (long*) malloc(N * sizeof(long)); for (int i = 0; i < N; i++) { C[i] = (char*) malloc(5 * sizeof(char)); } int best[3]; for (int i = 0; i < 3; i++) {best[i] = 0;} for (long i = 0; i < N; i++) { int e, t1, t2, t3, t4, t5, t6; scanf("%s %i %i %i %i %i %i %i", C[i], &e, &t1, &t2, &t3, &t4, &t5, &t6); int max = t1; int min = t1; if (t2 > max) {max = t2;} else if (t2 < min) {min = t2;} if (t3 > max) {max = t3;} else if (t3 < min) {min = t3;} if (t4 > max) {max = t4;} else if (t4 < min) {min = t4;} if (t5 > max) {max = t5;} else if (t5 < min) {min = t5;} if (t6 > max) {max = t6;} else if (t6 < min) {min = t6;} score[i] = 10 * e + t1 + t2 + t3 + t4 + t5 + t6 - min - max; if (score[i] > best[0]) {best[2] = best[1]; best[1] = best[0]; best[0] = score[i];} else if (score[i] > best[1]) {best[2] = best[1]; best[1] = score[i];} else if (score[i] > best[2]) {best[2] = score[i];} } for (int j = 0; j < 3; j++) { for(long long i = 0; i < N; i++) { if (score[i] == best[j]) {printf("%s %i\n",C[i],score[i]); score[i]++;} } } return 0; }