【NOIP2007】【Luogu1093】奖学金

problem

solution

codes

//模拟即可
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
    int id, ch, score;
    bool operator < (const node &x)const{
        if(score != x.score)return score > x.score;
        if(ch != x.ch)return ch > x.ch;
        return id < x.id;
    }
}a[310];
int main(){
    int n;  cin>>n;
    for(int i = 1; i <= n; i++){
        a[i].id = i;
        int x, y;  cin>>a[i].ch>>x>>y;
        a[i].score = a[i].ch+x+y;
    }
    sort(a+1,a+n+1);
    for(int i = 1; i <= 5; i++)
        cout<<a[i].id<<" "<<a[i].score<<"
";
    return 0;
} 
原文地址:https://www.cnblogs.com/gwj1314/p/9444698.html