70分求助!

P1093 [NOIP2007 普及组] 奖学金

qzhw @ 2021-09-19 10:02:48

#include<bits/stdc++.h>
using namespace std;
int n;
struct node
{
    int bh;
    int chinese;
    int maths;
    int english;
    int sum;
}a[305];
bool cmp(node x,node y)
{
    return x.sum>y.sum;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i].chinese>>a[i].maths>>a[i].english;
    for(int i=1;i<=n;i++)
    a[i].sum=a[i].chinese+a[i].maths+a[i].english;
    for(int i=1;i<=n;i++)
    a[i].bh=i;
    stable_sort(a+1,a+1+n,cmp);
    for(int i=1;i<=5;i++)
    {
        if(a[i].sum==a[i+1].sum)
        {
            if(a[i].chinese>a[i+1].chinese)
            swap(a[i].sum,a[i].sum);

        }
        cout<<a[i].bh<<" "<<a[i].sum<<"\n";
    }
    return 0;
}

by qzhw @ 2021-09-19 10:29:39

谢谢大家


by qzhwDGS @ 2021-09-19 10:30:06

@Waaifu_D

<有道理> && 问一下:初赛(阅读程序和补全程序)考什么难度的题?(入门?普及-、+?or 提高-、+)


by qzhwDGS @ 2021-09-19 10:32:34

@qzhw

你很不低调喂,F


by qzhw @ 2021-09-19 10:34:32

emmm...

F是?


by qzhw @ 2021-09-19 10:35:38

@qzhwDGS


by Waaifu_D @ 2021-09-19 10:36:28

@qzhwDGS 你说的应该是J组吧,J组的阅读程序和补全程序难度没提高-,+那么离谱,可能在绿-黄题左右?

顺便说下我个人觉得补全程序比阅读简单


by qzhw @ 2021-09-19 10:37:40

蒟蒻瑟瑟发抖


by qzhwDGS @ 2021-09-19 10:44:11

@Waaifu_D

我觉得都很难


by Alfred_zhc @ 2021-09-19 22:14:24

把cmp改成这样:```cpp

return a.score==b.score?(a.chi==b.chi?a.id<b.id:a.chi>b.chi):a.score>b.score; //score总分 id编号 chi语文


上一页 |