70.。。。怎么破?

P1093 [NOIP2007 普及组] 奖学金

xxfdzl @ 2016-12-17 09:54:27

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
int a[10000],b[10000],c[10000],s[10000],k[10000];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i]>>b[i]>>c[i];
        s[i]=a[i]+b[i]+c[i];
        k[i]=i;
    }
    for(int i=1;i<n;++i)
      for(int j=i+1;j<=n;++j)
        if(s[i]<s[j]||(s[i]==s[j]&&a[i]<a[j])||(s[i]==s[j]&&a[i]==a[j]&&k[i]>k[j]))
        {
            int p=s[i];
            s[i]=s[j];
            s[j]=p;
            int q=k[i];
            k[i]=k[j];
            k[j]=q;
        }
    for(int i=1;i<=5;++i)
      cout<<k[i]<<" "<<s[i]<<endl;
    return 0;
}

by xxfdzl @ 2016-12-17 11:21:50

已过


|