0分!

P1093 [NOIP2007 普及组] 奖学金

Dxj1107 @ 2022-11-20 21:35:31


#include<bits/stdc++.h>
using namespace std;
int a[305][4],b[305],c[305];
int main()
{
    int n,i,j;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=3;j++)
        {
            cin>>a[i][j];
            b[i]+=a[i][j];
        }
        c[i]=i;
    }
    sort(b+1,b+n+1);
    for(i=1;i<=5;i++)
    {
        if(b[i]==b[i-1])
        {
            if(a[i][1]>a[i-1][1])
            {
                cout<<i<<" "<<b[i]<<endl;
            }
            if(a[i][1]==a[i-1][1])
            {
                if(c[i]>c[i-1]) {cout<<i<<" "<<b[i]<<endl;}
                else {cout<<i-1<<" "<<b[i-1]<<endl;}
            }
            if(a[i][1]<a[i-1][1])
            {
                cout<<i-1<<" "<<b[i-1]<<endl;
            }
        }
    }
    return 0;
}

by pig2014 @ 2022-11-21 20:12:52

只有B(总分)参与了排序,A和C没排序诶...

这题最好用struct


by Dxj1107 @ 2022-11-27 14:49:54

@pig2014 az... 结构体wo记得wo学过 em。。。


by Dxj1107 @ 2022-11-27 14:50:50

可能我脑袋有点问题


|