社区讨论

测试能过但全WA

P1051[NOIP 2005 提高组] 谁拿了最多奖学金参与者 4已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@lo2kzz57
此快照首次捕获于
2023/10/23 15:33
2 年前
此快照最后确认于
2023/10/23 15:33
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
struct student
{
    string name;
    int fas, cds, pn;//avs表示期末平均成绩,cds表示班级评议成绩, pn表示论文数量
    char l, w;
    int cnt;
} a[105];
bool leader(int i)
{
    if(int(a[i].l) == 89)   return true;
    return false;
}
bool west(int i)
{
    if(int(a[i].w) == 89)   return true;
    return false;
}
int main()
{
    int n, tot = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i].name >> a[i].fas >> a[i].cds >> a[i].l >> a[i].w >> a[i].pn;
    }
    for(int i = 1; i <= n; i++)
    {
        if(a[i].fas > 80 && a[i].pn >= 1)   a[i].cnt += 8000;
        if(a[i].fas > 85 && a[i].cds > 80)   a[i].cnt += 4000;
        if(a[i].fas > 90)   a[i].cnt += 2000;
        if(a[i].fas > 85 && west(i))   a[i].cnt += 1000;
        if(a[i].cds > 80 && leader(i))   a[i].cnt += 850;
    }
    for(int i = 1; i <= n; i++)
    {
        tot += a[i].cnt;
    }
    for(int i = 1; i <= n; i++)
    {
        if(a[i].cnt < a[i+1].cnt)   swap(a[i], a[i+1]);
    }
    cout << a[1].name << endl;
    cout << a[1].cnt << endl;
    cout << tot << endl;
    return 0;
}

回复

3 条回复,欢迎继续交流。

正在加载回复...