【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<<"\n";
    return 0;
} 
posted @ 2018-06-05 21:27  gwj1139177410  阅读(98)  评论(0编辑  收藏  举报
选择