luogu1051 谁拿了最多奖学金

https://www.luogu.com.cn/problem/P1051

1.用cin输入字符串,省事

 

#include<bits/stdc++.h>
using namespace std;

struct stu{
    int num;
    string name;
    int score;
    int pyscore; 
    char gb;
    char xb;
    int lw;
    int tot;
};

struct stu a[110]; 

bool cmp(stu x,stu y)
{
    if (x.tot!=y.tot)
    return x.tot>y.tot;
    else x.num<y.num;
}
int main(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        a[i].num=i;
        cin>>a[i].name>>a[i].score>>a[i].pyscore>>a[i].gb>>a[i].xb>>a[i].lw;
        if(a[i].score>80&&a[i].lw>0) a[i].tot+=8000;
        if(a[i].score>85&&a[i].pyscore>80) a[i].tot+=4000;
        if(a[i].score>90) a[i].tot+=2000;
        if(a[i].score>85&&a[i].xb=='Y') a[i].tot+=1000;
        if(a[i].pyscore>80&&a[i].gb=='Y') a[i].tot+=850;
        cnt+=a[i].tot;
    }
    sort(a,a+n,cmp);
    cout<<a[0].name<<endl;
    cout<<a[0].tot<<endl;
    cout<<cnt<<endl;
    return 0;
}

 

posted on 2020-03-05 13:32  lyyyt  阅读(188)  评论(0编辑  收藏  举报