2 条题解

  • 0
    @ 2025-10-5 10:29:26
    #include<stdio.h>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    struct Mes{
        char id[13];
        int age;
        int index;
    };
    Mes M[100];
    bool cmp(Mes a,Mes b){
            if(a.age >= 60 && b.age < 60)return true;
            if(a.age < 60 && b.age >= 60)return false;
            if(a.age >= 60 && b.age >= 60){
                if(a.age != b.age)return a.age > b.age;
                else return a.index < b.index;
            }else {
                return a.index < b.index;
            }
            
    }
    int main(){
        int n;
        cin>>n;
        for(int i = 0;i < n;i++){
            cin>>M[i].id>>M[i].age;
            M[i].index = i;
        }
        sort(M,M+n,cmp);
        for(int i = 0;i < n;i++){
            printf("%s\n",M[i].id);
        }
    
    }//🎉️ 🎉️ 
    

    信息

    ID
    1126
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    (无)
    递交数
    18
    已通过
    9
    上传者