B1137 Final Grading (模拟有坑)

B1137 Final Grading (25分)

  • 坑1:题目的N的范围是10000,但三个N,所以数组要开到30000

then receive a final grade no less than 60 out of 100.

  • 坑2:G不能低于60,但不能高于100,题目不排除错误数据的情况,错误数据也不能输出

If some score does not exist, output "−1" instead.

  • 坑3:最后ranklist数据不存在的情况只有Gmid或Gfinal分数不存在,而不是去判是否是0//map默认不存在为0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define lowbit(i)((i)&(-i))
using namespace std;
typedef long long ll;
const int MAX=30005;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
const int SQR=633;
struct node
{
    string id;
    int Gp,Gm,Gf,G;
};
map<string,node>mp;
map<string,int>gm,gf;
vector<node>stu;
bool cmp(node a,node b)
{
    if(a.G!=b.G)
        return a.G>b.G;
    else if(a.id!=b.id)
        return a.id<b.id;
}
int main()
{
    string id;
    int score;
    int n,m,k;
    scanf("%d%d%d",&m,&n,&k);
    for(int i=0;i<m;i++)
    {
        cin>>id>>score;
        mp[id].Gp=score;
    }
    for(int i=0;i<n;i++)
    {
        cin>>id>>score;
        mp[id].Gm=score;
        gm[id]++;
    }
    for(int i=0;i<k;i++)
    {
        cin>>id>>score;
        mp[id].Gf=score;
        gf[id]++;
    }
    for(map<string,node>::iterator it=mp.begin();it!=mp.end();it++)
    {
        node temp;
        temp.id=it->first;
        temp.Gp=(it->second).Gp;
        temp.Gm=(it->second).Gm;
        temp.Gf=(it->second).Gf;
        if(temp.Gm>temp.Gf)
            temp.G=(int)(temp.Gm*0.4+temp.Gf*0.6+0.5);
        else
            temp.G=temp.Gf;
        if(temp.G>=60&&temp.Gp>=200&&temp.G<=100)
        stu.push_back(temp);
    }
    sort(stu.begin(),stu.end(),cmp);
    for(int i=0;i<stu.size();i++)
    {
        if(gf[stu[i].id]==0)
            stu[i].Gf=-1;
        if(gm[stu[i].id]==0)
            stu[i].Gm=-1;
        cout<<stu[i].id<<" "<<stu[i].Gp<<" "<<stu[i].Gm<<" "<<stu[i].Gf<<" "<<stu[i].G<<endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值