洛谷P1051 谁拿了最多奖学金
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define max_n 100
struct pel{
string name;
int ave;
int clas;
char std_a;
char std_e;
int art;
int sum;
int numb;
};
bool cmp(struct pel a, struct pel b) {
if(a.sum == b.sum) {
return a.numb < b.numb;
}
return a.sum > b.sum;
}
int main() {
int n, sum1 = 0;
struct pel stud[max_n + 5];
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> stud[i].name >> stud[i].ave >> stud[i].clas >> stud[i].std_a >> stud[i].std_e >> stud[i].art;
stud[i].numb = i;
stud[i].sum = 0;
if(stud[i].ave > 80 && stud[i].art >= 1) {
stud[i].sum += 8000;
}
if(stud[i].ave > 85 && stud[i].clas > 80) {
stud[i].sum += 4000;
}
if(stud[i].ave > 90) {
stud[i].sum += 2000;
}
if(stud[i].ave > 85 && stud[i].std_e == 'Y') {
stud[i].sum += 1000;
}
if(stud[i].ave > 80 && stud[i].std_a == 'Y') {
stud[i].sum += 850;
}
sum1 += stud[i].sum;
}
sort(stud + 1, stud + n + 1 ,cmp);
/*for(int i = 1; i <= n; i++) {
sum1 += stud[i].sum;
}*/
cout << stud[1].name << endl << stud[1].sum << endl << sum1 << endl;
}