2016huasacm暑假集训训练五 E - What Is Your Grade?

时间:2023-03-09 01:26:32
2016huasacm暑假集训训练五  E - What Is Your Grade?

题目链接:https://vjudge.net/contest/126708#problem/E

题意:给做出的题目个数,5个的100分,4个的前n/2的同学95,后n/2的90  后面一次类推,没做出来的全是50分  这个题只要模拟下就好了  先按题目个数拍好序 得到每个题目做出的人数,在打分,最后在按原来的顺序排序  ,在一次输出他们所得的分数;按原来的顺序排序可以先给每个要个变量记住他们的顺序,在排序就好

AC代码:

 #include <iostream>
#include<algorithm>
#include <string>
using namespace std;
struct Student
{
int garde;
string time;
int shunxu;
int fenshu;
};
bool cmp1(Student a,Student b) //按原顺序排序的比较函数
{
return a.shunxu<b.shunxu;
}
bool cmp(Student a,Student b) //按题目个数排序的比较函数
{
if(a.garde == b.garde)
{
return a.time < b.time;
}
else return a.garde < b.garde;
}
int main()
{
int t,t1,t2,t3,t4,l1,l2,l3,l4;
while(cin>>t)
{
if(t==-) break;
Student a[];
t1 = ;
t2= ;
t3=;
t4=;
for(int i = ; i < t; i ++)
{
cin>>a[i].garde>>a[i].time;
a[i].shunxu = i;
if(a[i].garde == ) t1 ++; //统计各个题目的人数
if(a[i].garde == ) t2 ++;
if(a[i].garde == ) t3 ++;
if(a[i].garde == ) t4 ++;
}
sort(a,a+t,cmp);
t1 = t1/;
t2=t2/;
t3=t3/;
t4=t4/;
l1=;
l2=;
l3=;
l4=;
for(int i =; i < t; i++) //给每个按照打分制度同学打分
{
if(a[i].garde == )
{
if(l1<=t1)
{
a[i].fenshu = ;
l1++;
}
else a[i].fenshu = ;
}
if(a[i].garde == )
{
if(l2<=t2)
{
a[i].fenshu = ;
l2++;
}
else a[i].fenshu = ;
}
if(a[i].garde == )
{
if(l3<=t3)
{
a[i].fenshu = ;
l3++;
}
else a[i].fenshu = ;
}
if(a[i].garde == )
{
if(l4<=t4)
{
a[i].fenshu = ;
l4++;
}
else a[i].fenshu = ;
}
if(a[i].garde == ) a[i].fenshu = ;
if(a[i].garde == ) a[i].fenshu = ;
}
sort(a,a+t,cmp1); //按原序拍好序 在依次输出分数
for(int i = ; i <t; i++)
cout<<a[i].fenshu<<endl;
cout<<endl;
}
return ;
}