链接 :[NOIP2005 提高组] 谁拿了最多奖学金 - 洛谷
总代码:
#include <bits/stdc++.h>
using namespace std;
struct stu{
int id;
string name;
int endScore;
int pingScore;
char Gan;
char west;
int Paper;
int sumMoney;
};
bool cmp(stu a, stu b){
if(a.sumMoney != b.sumMoney){
return a.sumMoney > b.sumMoney;
}else{
return a.id < b.id;
}
}
int main(){
int n;
cin >> n;
stu s[n];
for(int i = 0; i < n; i++){
string name;
int endScore, pingScore, Paper, sumMoney = 0;
char Gan, west;
cin >> name >> endScore >> pingScore >> Gan >> west >> Paper;
s[i] = {i, name, endScore, pingScore, Gan, west, Paper};
if(endScore > 80 && Paper >= 1){
sumMoney += 8000;
}
if(endScore > 85 && pingScore > 80){
sumMoney += 4000;
}
if(endScore > 90){
sumMoney += 2000;
}
if(endScore > 85 && west == 'Y'){
sumMoney += 1000;
}
if(pingScore > 80 && Gan == 'Y'){
sumMoney += 850;
}
s[i].sumMoney = sumMoney;
}
sort(s, s+n, cmp);
int sum = 0;
for(int i = 0; i < n; i++){
sum += s[i].sumMoney;
}
cout << s[0].name << endl;
cout << s[0].sumMoney << endl;
cout << sum << endl;
return 0;
}