1015.德才论

这里写图片描述

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct student
{
public:
    int id;
    int des;
    int cais;
    int zong;
};

bool comp(student a, student b)
{
    if (a.zong>b.zong)
    {
        return true;
    }
    else if (a.zong==b.zong)
    {
        if (a.des>b.des)
        {
            return true;
        }
        else if (a.des==b.des)
        {
            if (a.id<b.id)
            {
                return true;
            }
        }
    }
    return false;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int n;
    cin >> n;
    int low, high;
    cin >> low >> high;
    int id_temp,de_temp,cai_temp;
    vector<student> s1, s2, s3, s4;
    student temp;
    int cnt = 0;
    for (int i = 0; i < n;++i)
    {
        cin >> id_temp >> de_temp >> cai_temp;
        temp.id = id_temp;
        temp.des = de_temp;
        temp.cais = cai_temp;
        temp.zong = de_temp + cai_temp;
        if (de_temp>=low&&cai_temp>=low)
        {
            ++cnt;
            if (de_temp >= high&&cai_temp >= high)
            {
                s1.push_back(temp);
            }
            else if (de_temp>=high&&cai_temp<high)
            {
                s2.push_back(temp);
            }
            else if (de_temp < high&&cai_temp < high&&de_temp >= cai_temp)
            {
                s3.push_back(temp);
            }
            else
                s4.push_back(temp);
        }
    }
    cout << cnt << endl;
    sort(s1.begin(), s1.end(), comp);
    sort(s2.begin(), s2.end(), comp);
    sort(s3.begin(), s3.end(), comp);
    sort(s4.begin(), s4.end(), comp);
    for (auto c:s1)
    {
        printf("%d %d %d\n", c.id, c.des, c.cais);                                   //使用cout输出会超时
    }
    for (auto c : s2)
    {
        printf("%d %d %d\n", c.id, c.des, c.cais);
    }
    for (auto c : s3)
    {
        printf("%d %d %d\n", c.id, c.des, c.cais);
    }
    for (auto c : s4)
    {
        printf("%d %d %d\n", c.id, c.des, c.cais);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值