50分,求助

P1093 [NOIP2007 普及组] 奖学金

蔡锷4455 @ 2021-06-17 19:00:47


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int const maxn=310;
int n;
struct student
{
    int id,chinese,total;
}a[maxn];
int cmp(student a,student b)
{
    return a.total>b.total;
    return a.chinese>b.chinese;
    return a.id>b.id;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int math,english;
        cin>>a[i].chinese>>math>>english;
        a[i].total=a[i].chinese+math+english;
        a[i].id=i+1;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<5;i++)
        cout<<a[i].id<<" "<<a[i].total<<endl;
    return 0;
}```

by yyandy @ 2021-06-17 19:05:56

cmp写错了@蔡锷4455


by yyandy @ 2021-06-17 19:09:37

int cmp(student a,student b)
{
    if(a.total!=b.total)
    return a.total>b.total;
    if(a.chinese!=b.chinese)
    return a.chinese>b.chinese;
    return a.id<b.id;
}

@蔡锷4455


by 蔡锷4455 @ 2021-06-17 19:18:46

@yyandy 还是不行,变成90分了


by yyandy @ 2021-06-17 19:29:21

没问题啊@蔡锷4455


by 蔡锷4455 @ 2021-06-17 19:37:12

第八个测试点是WA


by 蔡锷4455 @ 2021-06-17 19:39:07

@yyandy


by yyandy @ 2021-06-17 21:02:42

@蔡锷4455 我都测过了没问题,所以你把现在的代码发过来吧


|