求助大佬

P1093 [NOIP2007 普及组] 奖学金

Huojinyi @ 2024-12-29 11:53:39

0分 ┭┮﹏┭┮

#include<bits/stdc++.h>
using namespace std;
int n;
int a[10001],b[10001],c[10001];
int sum[10001],ans=0,k;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
        sum[i]+=a[i]+b[i]+c[i];
    }
    for(int i=1;i<=5;i++){
        ans=0,k=0;
        for(int j=1;j<=n;j++){
            if(ans<sum[i]){
                ans=sum[i];
                k=i;
            }else if(ans==sum[i]){
                if(a[k]<a[i]||b[k]<b[i]||c[k]<c[i]){
                    k=i;
                }else if(a[k]==a[i]&&b[k]==b[i]&&c[k]==c[i]){
                    k=min(k,i);
                }
            }
        }
        cout<<k<<" "<<ans<<endl;
        sum[k]=-1;
    }
    return 0;
}

by Huojinyi @ 2024-12-29 11:57:29

问题已解决


|