哪里错了

P1093 [NOIP2007 普及组] 奖学金

_qinxili_ @ 2023-11-28 19:54:22

#include<bits/stdc++.h>
using namespace std;
struct stu
{
    int id,yv,sx,yy,sm;
}xs[310];
bool cmp(stu x,stu y)
{
    if(x.sm>y.sm)
    {
        return true;
    }
    else if(x.sm<y.sm)
    {
        return false;
    }
    else
    {
        if(x.yv>y.yv)
        {
            return true;
        }
        else if(x.yv<y.yv)
        {
            return false;
        }
        else
        {
            if(x.id<y.id)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        xs[i].id=i;
        cin>>xs[i].yv>>xs[i].sx>>xs[i].yy; 
        xs[i].sm=xs[i].yv+xs[i].sx+xs[i].yy;
    }
    sort(xs+1,xs+1+n,cmp);
    for(int i=1; i<=5; i++)
    {
        cout<<xs[i].id<<" "<<xs[i].sm<<"\n";
    }
    return 0;
}

测试点8错了


by _qinxili_ @ 2023-11-28 19:57:16

emmm....自己改对了


|