After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤), which is the number of testees. Then N lines follow, each gives the information of a testee in the following format:

ID Score School

where ID is a string of 6 characters with the first one representing the test level: B stands for the basic level, A the advanced level and T the top level; Score is an integer in [0, 100]; and School is the institution code which is a string of no more than 6 English letters (case insensitive). Note: it is guaranteed that ID is unique for each testee.

Output Specification:

For each case, first print in a line the total number of institutions. Then output the ranklist of institutions in nondecreasing order of their ranks in the following format:

Rank School TWS Ns

where Rank is the rank (start from 1) of the institution; School is the institution code (all in lower case); ; TWS is the total weighted score which is defined to be the integer part of ScoreB/1.5 + ScoreA + ScoreT*1.5, where ScoreX is the total score of the testees belong to this institution on level X; and Ns is the total number of testees who belong to this institution.

The institutions are ranked according to their TWS. If there is a tie, the institutions are supposed to have the same rank, and they shall be printed in ascending order of Ns. If there is still a tie, they shall be printed in alphabetical order of their codes.

Sample Input:

10
A57908 85 Au
B57908 54 LanX
A37487 60 au
T28374 67 CMU
T32486 24 hypu
A66734 92 cmu
B76378 71 AU
A47780 45 lanx
A72809 100 pku
A03274 45 hypu

Sample Output:

5
1 cmu 192 2
1 au 192 3
3 pku 100 1
4 hypu 81 2
4 lanx 81 2
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef struct NODE{
string scId;
int Asum, Bsum, Tsum, TWS;
int stuNum, rank;
NODE(){
Asum = ; Bsum = ; Tsum = ; stuNum = ;
TWS = ;
}
}info;
bool cmp(info a, info b){
if(a.TWS != b.TWS){
return a.TWS > b.TWS;
}else{
if(a.stuNum != b.stuNum)
return a.stuNum < b.stuNum;
else return a.scId < b.scId;
}
}
info school[];
map<string, int>mp;
int pt = ;
void str2Low(string &ss){
for(int i = ; i < ss.length(); i++){
if(ss[i] >= 'A' && ss[i] <= 'Z'){
ss[i] = ss[i] - 'A' + 'a';
}
}
}
int main(){
int N;
scanf("%d", &N);
for(int i = ; i < N; i++){
string id, sch;
int point;
cin >> id >> point >> sch;
str2Low(sch);
int index;
if(mp.count(sch) == ){
mp[sch] = pt++;
index = pt - ;
school[index].scId = sch;
}else{
index = mp[sch];
}
if(id[] == 'A'){
school[index].Asum += point;
}else if(id[] == 'B'){
school[index].Bsum += point;
}else{
school[index].Tsum += point;
}
school[index].stuNum++;
}
for(int i = ; i < pt; i++){
school[i].TWS = (double)school[i].Bsum / 1.5 + (double)school[i].Asum + (double)school[i].Tsum * 1.5;
}
sort(school, school + pt, cmp);
school[].rank = ;
cout << pt << endl;
for(int i = ; i < pt; i++){
if(school[i].TWS == school[i - ].TWS){
school[i].rank = school[i - ].rank;
}else{
school[i].rank = i + ;
}
}
for(int i = ; i < pt; i++){
cout << school[i].rank << " " << school[i].scId << " " << school[i].TWS << " "<<school[i].stuNum << endl;
}
cin >> N;
return ;
}

最新文章

  1. [转] eclipse SVN中文件修改后图标不变黑星解决
  2. Recall, Precision and F-score
  3. CF #296 (Div. 1) A. Glass Carving 线段树
  4. Codeforces Beta Round #2
  5. [SoapUI] JDBC 请求连接SQL Sever,MySQL
  6. ASP.NET MVC中的模型装配 封装方法 非常好用
  7. Android优化—— Google 发布 Android 性能优化典范
  8. Maven教程(转载)
  9. 怎样用PHP制作验证码呢?
  10. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)
  11. C++ 方法隐藏
  12. mvn常见命令
  13. gulp 小坑一个
  14. 使用jquery中height()方法获取各种高度
  15. 问题 1923: [蓝桥杯][算法提高VIP]学霸的迷宫 (BFS)
  16. LeetCode 57 插入区间
  17. vue表单校验提交报错TypeError: Cannot read property &#39;validate&#39; of undefined
  18. Vue中出现Do not use built-in or reserved HTML elements as component id:footer等等vue warn问题
  19. SpringMVC中参数接收
  20. webpack config

热门文章

  1. 50分钟学会Laravel 50个小技巧(基于laravel5.2,仅供参考)
  2. Day 4-3 os &amp; sys模块
  3. Django Rest framework 框架之解析器
  4. python数学第三天【方向导数】
  5. todo项目总结
  6. GA-H61M-DS2 BIOS SETTING
  7. JUC同步锁(五)
  8. loj6270
  9. 【Python】一份非常好的Matplotlib教程
  10. linux目录文件及系统启动知识