1012 The Best Rank (25 分)
发布日期:2021-08-19 11:10:19 浏览次数:2 分类:技术文章

本文共 2829 字,大约阅读时间需要 9 分钟。

1012 The Best Rank (25 分)

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C- C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasizing on their best ranks -- that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student.

For example, The grades of CME and A - Average of 4 students are given as the following:

StudentID  C  M  E  A310101     98 85 88 90310102     70 95 88 84310103     82 87 94 88310104     91 91 91 91

Then the best ranks for all the students are No.1 since the 1st one has done the best in C Programming Language, while the 2nd one in Mathematics, the 3rd one in English, and the last one in average.

Input Specification:

Each input file contains one test case. Each case starts with a line containing 2 numbers N and M (2000), which are the total number of students, and the number of students who would check their ranks, respectively. Then N lines follow, each contains a student ID which is a string of 6 digits, followed by the three integer grades (in the range of [0, 100]) of that student in the order of CM and E. Then there are M lines, each containing a student ID.

Output Specification:

For each of the M students, print in one line the best rank for him/her, and the symbol of the corresponding rank, separated by a space.

The priorities of the ranking methods are ordered as A C M E. Hence if there are two or more ways for a student to obtain the same best rank, output the one with the highest priority.

If a student is not on the grading list, simply output N/A.

Sample Input:

5 6310101 98 85 88310102 70 95 88310103 82 87 94310104 91 91 91310105 85 90 90310101310102310103310104310105999999

Sample Output:

1 C1 M1 E1 A3 AN/A 分析:sort排序题,由于要记录每科成绩的排名,可以用Rank[id][now]来记录学科排名,如果直接记录在结构体里面会超时,因为每次查询时需要遍历一遍,查询数量足够大的时候会超时。
1 /** 2 * Copyright(c) 3 * All rights reserved. 4 * Author : Mered1th 5 * Date : 2019-02-25-15.41.18 6 * Description : A1012 7 */ 8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 using namespace std;19 struct Student{20 int id;21 int grade[4];//4门成绩22 }stu[2010];23 char course[4]={ 'A','C','M','E'};24 int now;25 bool cmp(Student a,Student b){26 return a.grade[now]>b.grade[now];27 }28 int Rank[10000000][4]={ 0};29 int main(){30 #ifdef ONLINE_JUDGE31 #else32 freopen("1.txt", "r", stdin);33 #endif34 int n,m;35 scanf("%d%d",&n,&m);36 for(int i=0;i

 

 

转载于:https://www.cnblogs.com/Mered1th/p/10431864.html

转载地址:https://blog.csdn.net/weixin_30924087/article/details/97034632 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Tutorial on Losses in Convolutional Neural Networks(edit 2)
下一篇:centos7下kubernetes(6。kubernetes创建资源的两种方式)

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月11日 05时16分54秒