1 条题解

  • 0
    @ 2022-9-29 10:17:11
    #include <bits/stdc++.h>
    using namespace std;
    struct Peo {
        string ID; //ID
        int age;   //年龄
        int logId; //登记顺序
    };
    int n;
    Peo a[105];
    //自定义排序规则
    bool cmp(Peo x, Peo y)
    {
        //1.
        if ((x.age >= 60) != (y.age >= 60))
            return (x.age >= 60) && (y.age <= 60);
        //2.
        if (x.age >= 60)
        {    
            if(x.age != y.age)
                return x.age > y.age;
            else
                return x.logId < y.logId;
        }
        //3
        return x.logId < y.logId;    
    }
    int main()
    {
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i].ID >> a[i].age;
            a[i].logId = i;
        }
        sort(a + 1, a + n + 1, cmp);
        for (int i = 1; i <= n; i++)
            cout << a[i].ID << "\n";
        return 0;
    }
    
    
    • 1

    信息

    ID
    403
    时间
    1000ms
    内存
    128MiB
    难度
    3
    标签
    (无)
    递交数
    58
    已通过
    31
    上传者