A1036 Boys vs Girls (25)

摘要
Title: A1036 Boys vs Girls (25)
Tag: 模拟
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

A1036 Boys vs Girls (25)

  • 题意

    This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.

  • 思路

    求出女生第一名与男生倒数第一名的分数差距

  • 代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    /*
    * @Author: NEFU AB-IN
    * @Date: 2023-01-08 18:55:28
    * @FilePath: \GPLT\A1036\A1036.cpp
    * @LastEditTime: 2023-01-08 18:55:45
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #undef int

    #define SZ(X) ((int)(X).size())
    #define IOS \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr); \
    cout.tie(nullptr)
    #define DEBUG(X) cout << #X << ": " << X << '\n'
    typedef pair<int, int> PII;

    const int N = 1e5 + 10, INF = 0x3f3f3f3f;
    struct sa
    {
    string id, word;
    };

    signed main()
    {
    int n;
    cin >> n;
    int grade_F = -1, grade_M = 101, ans = 0;
    string name_F, id_F, name_M, id_M;
    for (int i = 0; i < n; ++i)
    {
    string name, sex, id;
    int grade;
    cin >> name >> sex >> id >> grade;
    if (sex == "M" && grade_M > grade)
    {
    name_M = name;
    grade_M = grade;
    id_M = id;
    }
    if (sex == "F" && grade_F < grade)
    {
    name_F = name;
    grade_F = grade;
    id_F = id;
    }
    }
    if (grade_F == -1)
    {
    cout << "Absent\n";
    cout << name_M << " " << id_M << '\n';
    cout << "NA\n";
    }
    else if (grade_M == 101)
    {
    cout << name_F << " " << id_F << '\n';
    cout << "Absent\n";
    cout << "NA\n";
    }
    else
    {
    cout << name_F << " " << id_F << '\n';
    cout << name_M << " " << id_M << '\n';
    cout << grade_F - grade_M << '\n';
    }
    return 0;
    }
使用搜索:谷歌必应百度