1015 德才论
1015 德才论
1015 德才论
运行超时!!!!!!!

#include <iostream>

#include<algorithm>
using namespace std;
struct Chengji
{
    int number;
    int de;
    int cai;
    int score;
};
bool cmp(Chengji a, Chengji b)
{
    if(a.score == b.score)
    {
        if(a.de == b.de)
            return a.number<b.number;
        return a.de>b.de;
    }
    return a.score>b.score;
}
int main()
{
    int N,L,H;
    cin>>N>>L>>H;
    Chengji chengji[N];
    Chengji t1[N],t2[N],t3[N],t4[N];
    int p1=0,p2=0,p3=0,p4=0;
    int counter=0;
    for(int i=0;i<N;i++)
    {
        cin>>chengji[i].number>>chengji[i].de>>chengji[i].cai;
        chengji[i].score=chengji[i].de+chengji[i].cai;
        if(chengji[i].de>=L&&chengji[i].cai>=L)
        {
            counter++;
        }
    }
    cout<<counter<<endl;
    sort(chengji,chengji+N,cmp);
    for(int j1=0;j1<N;j1++)
    {
        if(chengji[j1].de>=H&&chengji[j1].cai>=H)
        {
            t1[p1++]=chengji[j1];
        }
        if(chengji[j1].de>=H&&chengji[j1].cai>=L&&chengji[j1].cai<H)
        {
            t2[p2++]=chengji[j1];
        }
        if(chengji[j1].de<H&&chengji[j1].de>=chengji[j1].cai&&chengji[j1].cai>=L)
        {
            t3[p3++]=chengji[j1];
        }
        if(chengji[j1].de<H&&chengji[j1].de<chengji[j1].cai&&chengji[j1].de>=L)
        {
           t4[p4++]=chengji[j1];
        }
    }
    for(int j2=0;j2<p1;j2++)
    {
        cout<<t1[j2].number<<" "<<t1[j2].de<<" "<<t1[j2].cai<<endl;
    }
    for(int j3=0;j3<p2;j3++)
    {
        cout<<t2[j3].number<<" "<<t2[j3].de<<" "<<t2[j3].cai<<endl;
    }
    for(int j4=0;j4<p3;j4++)
    {
        cout<<t3[j4].number<<" "<<t3[j4].de<<" "<<t3[j4].cai<<endl;
    }
    for(int j5=0;j5<p4;j5++)
    {
        cout<<t4[j5].number<<" "<<t4[j5].de<<" "<<t4[j5].cai<<endl;
    }
    return 0;
}

相关文章: