#include #include #include using namespace std; struct Team { string code; int score; int index; bool operator<(const Team& other) const { if (score == other.score) { return index > other.index; } return score < other.score; } }; void insertSorted(vector& vec, Team value) { auto it = lower_bound(vec.begin(), vec.end(), value); vec.insert(it, value); } vector v; int n, m, p, e; int min_e, max_e, sum; string c; int main() { cin>>n; for (int i = 1; i <= n; i++) { Team team; cin>>team.code; cin>>p; min_e = 100; max_e = -1; sum = 0; for (int j = 1; j <= 6; j++) { cin>>e; if (max_e < e) { max_e = e; } if (min_e > e) { min_e = e; } sum += e; } sum -= min_e; sum -= max_e; team.score = p * 10 + sum; team.index = i; insertSorted(v, team); } for (int i = n - 1; i >= n - 3; i--) { cout<= 0 && v[i].score == v[n - 3].score) { cout<