1012. The Best Rank (25)
来源:互联网 发布:mysql 初始化root密码 编辑:程序博客网 时间:2024/05/22 03:36
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 Algebra), 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 C, M, E 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
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 C, M and E. Then there are M lines, each containing a student ID.
Output
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 Input5 6310101 98 85 88310102 70 95 88310103 82 87 94310104 91 91 91310105 85 90 90310101310102310103310104310105999999Sample Output
1 C1 M1 E1 A3 AN/A
#include <iostream>#include <string>#include <vector>#include <map>using namespace std;int main(){ char p[5]="EMCA"; map<string,int>studentNoIndex;//学生学号索引. int rank[4][102]={0};//0-100分每一分对应得排名.共3科加平均分. int scores[4][102]={0};//0-100每一分对于的人数,共3科加平均分 int n,m,i,j,c,M,e; string studentNo; cin>>n>>m; vector<vector<int>>students(n,vector<int>(4,0));//学生表,每个学生有4个分数. for (i=0; i<n; i++) {//初始化 cin>>studentNo>>c>>M>>e; studentNoIndex[studentNo]=i; students[i][0]=e; students[i][1]=M; students[i][2]=c; int ave=(c+M+e)/3; students[i][3]=ave; scores[0][e]++; scores[1][M]++; scores[2][c]++; scores[3][ave]++; } for (int i=0; i<4; i++) {//初始化排名 rank[i][101]=1; for (j=100; j>=0; j--) { rank[i][j] = rank[i][j+1]+scores[i][j+1]; } } for (i=0; i<m; i++) { cin>>studentNo; map<string,int>::iterator it = studentNoIndex.find(studentNo); if(it==studentNoIndex.end()){ cout<<"N/A"<<endl; }else{ int NoIndex=it->second; int index = 0,minRank=rank[0][students[NoIndex][0]]; for (j=1; j<4; j++) { if (rank[j][students[NoIndex][j]]<=minRank) { index = j; minRank =rank[j][students[NoIndex][j]]; } } cout<<minRank<<" "<<p[index]<<endl; } } return 0;}
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 论文笔记《Convolutional Neural Networks for Sentence Classification》
- noj1031建筑群最长坡值
- 解决Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
- 操作系统 汤子瀛版 读书总结
- 手机图片js在线剪切
- 1012. The Best Rank (25)
- 20个非常有用的Java程序片段
- Socket编程及mina框架简单示例
- 莫队算法(最小曼哈顿生成树或者分块处理)
- 运算符的小技巧或容易出错的地方
- poj 3368 Frequent values 线段树 离散化
- Codeforces 611D:New Year and Ancient Prophecy DP 分块记录最后一个
- windows注册表编程
- 【IOI2001】【poj1195】Mobile phones(二维树状数组)