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;
}