1 solutions

  • 0
    @ 2025-9-30 13:15:30
    #include <iostream>
    #include <string>
    using namespace std;
    struct Student {
        string name;
        int chinese, math, english;
        int total;
    };
    int main() {
        int N;
        cin >> N;
        Student students[N];
        for (int i = 0; i < N; ++i) {
            cin >> students[i].name >> students[i].chinese >> students[i].math >> students[i].english;
            students[i].total = students[i].chinese + students[i].math + students[i].english;
        }
        int maxIndex = 0;
        for (int i = 1; i < N; ++i) {
            if (students[i].total > students[maxIndex].total) {
                maxIndex = i;
            }
        }
        cout << students[maxIndex].name << " " 
             << students[maxIndex].chinese << " " 
             << students[maxIndex].math << " " 
             << students[maxIndex].english << endl;
        
        return 0;
    }
    • 1

    Information

    ID
    4717
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    2
    Tags
    (None)
    # Submissions
    3
    Accepted
    3
    Uploaded By