#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Student {
    string name;
    int chinese;
    int math;
    int english;
    int total() const { return chinese + math + english; }
    bool isKeyStudent() const {
        return (chinese >= 108 || math >= 108 || english >= 108) && total() >= 324;
    }
};

int main() {
    cout << "欢迎来到未来学校成绩管理系统(三科版,满分120分)!" << endl;
    cout << "=============================================" << endl;
    
    vector<Student> students;
    int count;
    
    cout << "请输入学生人数: ";
    cin >> count;
    
    for(int i=0; i<count; i++) {
        Student s;
        cout << "请输入第" << i+1 << "个学生的信息(姓名 语文 数学 英语): ";
        cin >> s.name >> s.chinese >> s.math >> s.english;
        students.push_back(s);
    }
    
    sort(students.begin(), students.end(), 
        [](const Student& a, const Student& b){ return a.total() > b.total(); });
    
    cout << "\n成绩排名(按总分):\n";
    for(int i=0; i<students.size(); i++) {
        cout << "第" << i+1 << "名: " << students[i].name 
             << " (总分:" << students[i].total() 
             << " 语文:" << students[i].chinese
             << " 数学:" << students[i].math
             << " 英语:" << students[i].english << ")";
        if(students[i].isKeyStudent()) {
            cout << " [重点培养对象]";
        }
        cout << endl;
    }

    cout << "\n重点培养对象名单:\n";
    bool firstKeyStudent = true;
    for(const auto& s : students) {
        if(s.isKeyStudent()) {
            if(firstKeyStudent) {
                cout << s.name << " (总分:" << s.total() 
                     << " 语文:" << s.chinese
                     << " 数学:" << s.math
                     << " 英语:" << s.english << ") [首要重点培养对象]\n";
                firstKeyStudent = false;
            } else {
                cout << s.name << " (总分:" << s.total() 
                     << " 语文:" << s.chinese
                     << " 数学:" << s.math
                     << " 英语:" << s.english << ")\n";
            }
        }
    }
    return 0;
}