首页 > 其他 > 详细

1055 The World's Richest (25 分)

时间:2021-02-15 22:59:02      阅读:18      评论:0      收藏:0      [点我收藏+]

暴力代码,水了\(22pts\)

const int N=1e5+10;
struct Node
{
    string name;
    int age;
    int worth;
    bool operator<(const Node &W) const
    {
        if(worth != W.worth) return worth > W.worth;
        if(age != W.age) return age < W.age;
        return name < W.name;
    }
}a[N];
int n,m;

int main()
{
    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>a[i].name>>a[i].age>>a[i].worth;

    int kase=1;
    while(m--)
    {
        int k,l,r;
        cin>>k>>l>>r;

        vector<Node> v;
        for(int i=0;i<n;i++)
            if(a[i].age >= l && a[i].age <= r)
                v.pb(a[i]);

        cout<<"Case #"<<kase++<<‘:‘<<endl;

        if(v.size() == 0) cout<<"None"<<endl;
        else
        {
            sort(v.begin(),v.end());
            for(int i=0;i<k && i<v.size();i++)
                cout<<v[i].name<<‘ ‘<<v[i].age<<‘ ‘<<v[i].worth<<endl;
        }
    }
    //system("pause");
    return 0;
}

1055 The World's Richest (25 分)

原文:https://www.cnblogs.com/fxh0707/p/14403398.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!