Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑
|
Input 测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N
|
Output 对每场考试,首先在第1行输出不低于分数线的考生人数n,随后n行按分数从高
|
Sample Input 4 5 2510 10 12 13 15CS004 3 5 1 3CS003 5 2 4 1 3 5CS002 2 1 2CS001 3 2 3 51 2 4010 30CS001 1 22 3 2010 10 10CS000000000000000001 0CS000000000000000002 2 1 20
|
Sample Output 3CS003 60CS001 37CS004 3701CS000000000000000002 20
Hint
Huge input, scanf is recommended.
|
|
Source 浙大计算机研究生复试上机考试-2005年
|
Recommend JGShining |
#include<stdio.h>
#include<string>
#include"algorithm"
using namespace std;
#define MAXM 10
#define MAXN 1000
#define MAXID 21
struct Student
{
char ID[MAXID];
int slove[MAXN];
int point;
int slvNum;
};
Student stu[MAXN];
int proPoint[MAXM];
int cmp(const Student &a, const Student &b)
{
if (a.point == b.point)
return strcmp(a.ID, b.ID) > 0 ? 0 : 1;
else
return a.point > b.point;
}
int main()
{
//freopen("f://in.txt", "r", stdin);
//freopen("f://out.txt", "w", stdout);
int n, proNum, minPoint;
while (scanf("%d", &n)!=EOF && n != 0)
{
scanf("%d %d", &proNum, &minPoint);
memset(proPoint, 0, sizeof(proPoint));
memset(stu, 0, sizeof(stu));
for (int i = 0; i < proNum; i++)
scanf("%d", &proPoint[i]);
int count = 0;
for (int i = 0; i < n; i++)
{
scanf("%s %d", stu[i].ID, &stu[i].slvNum);
stu[i].point = 0;
for (int j = 0; j < stu[i].slvNum;j++)
{
scanf("%d", &stu[i].slove[j]);
stu[i].point += proPoint[stu[i].slove[j]-1];
}
if (stu[i].point >= minPoint)
count++;
}
sort(stu, stu + n, cmp);
printf("%d\n", count);
for (int i = 0; i < count; i++)
{
printf("%s %d\n", stu[i].ID, stu[i].point);
}
}
return 0;
}