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 (≤10​5​​), 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; Scoreis 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<vector>
#include<map>
#include<algorithm>
using namespace std; struct School{
string name;
double grade;
int stuNum;
}school; bool cmp(School a,School b){
if(a.grade != b.grade) return a.grade > b.grade;
else if(a.stuNum != b.stuNum)
return a.stuNum < b.stuNum;
else return a.name < b.name;
} int main(){
int n;
cin >> n; string s,str;
vector<School> sch,ans;
map<string,int> idx;
int cnt = ;
double score; for(int i = ; i < n; i++){
cin >> s >> score >> str;
for(int j = ; j < str.length(); j++){
if(str[j] >= 'A' && str[j] <= 'Z')
str[j] = str[j] - 'A' + 'a';
}
if(s[] == 'B') score /= 1.5;
else if(s[] == 'T') score *= 1.5;
if(idx.count(str) == ){
idx[str] = cnt++;
school.name = str;
school.grade = ;
school.stuNum = ;
sch.push_back(school); }
sch[idx[str]-].grade += score;
sch[idx[str]-].stuNum++;
} for(int i = ; i < sch.size(); i++){
sch[i].grade = (int)sch[i].grade;
}
sort(sch.begin(),sch.end(),cmp);
int rank = ;
printf("%d\n",sch.size());
cout << rank << " "<< sch[].name << " " << sch[].grade << " " << sch[].stuNum << endl;
for(int i = ; i < sch.size(); i++){
if(sch[i].grade != sch[i-].grade){
rank = i + ;
} cout << rank << " "<< sch[i].name << " " << sch[i].grade << " " << sch[i].stuNum << endl;
}
return ;
}

1141 PAT Ranking of Institutions (25 分)的更多相关文章

  1. 1141 PAT Ranking of Institutions[难]

    1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...

  2. [PAT] 1141 PAT Ranking of Institutions(25 分)

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  3. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  4. PAT 1141 PAT Ranking of Institutions

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  5. 1141 PAT Ranking of Institutions

    题意:给出考生id(分为乙级.甲级和顶级),取得的分数和所属学校.计算各个学校的所有考生的带权总成绩,以及各个学校的考生人数.最后对学校进行排名. 思路:本题的研究对象是学校,而不是考生!因此,建立学 ...

  6. PAT_A1141#PAT Ranking of Institutions

    Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...

  7. PTA PAT排名汇总(25 分)

    PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...

  8. PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  9. A1141. PAT Ranking of Institutions

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

随机推荐

  1. Ubuntu 查看软件版本

    Boost dpkg -S /usr/include/boost/version.hpp OpenCV pkg-config --modversion opencv

  2. java方法学习记录

    ---恢复内容开始--- 方法重载:两个方法有相同的名字,但参数不同,就是方法重载,且不能仅仅依据修饰符或者返回类型的不同来重载方法. 命令行参数的使用 有时候你希望运行一个程序时候再传递给它消息.这 ...

  3. hdu 4269 Defend Jian Ge

    #include <cctype> #include <algorithm> #include <vector> #include <string> # ...

  4. location.replace() keeps the history under control

    from https://dev.opera.com/articles/efficient-javascript Occasionally, it is necessary to change the ...

  5. eclipse导入tomcat

    官网下载tomcat压缩包 官网:http://tomcat.apache.org/ tomcat8:链接:http://pan.baidu.com/s/1kVHAEoR 密码:kyt8 tomcat ...

  6. XE中rectangle实现渐变

    Fill -> Kind -> Gradient(选项) -> Gradient(Edit) 添加颜色即可

  7. JavaScript对象(持续更新中)

    1Array对象 2.Boolean对象 3.Date对象 4.Math对象 5.Number对象 6.String对象 ※String.replace():替换字符串 实例: str.replace ...

  8. IT学习资源

    介绍个人微信公众平台:Web开发笔记 含有免费学习资源,个人学习笔记,技术文章分享  资源篇 1.webapp书城开发 链接: https://pan.baidu.com/s/1pMHGKrh 密码: ...

  9. 《C#多线程编程实战》2.10 SpinWait

    emmm 这个SpinWait 中文是自旋等待的意思. 所谓自旋,就是自己追自己影子,周伯通的左右手互博,不好听就是放屁自己追着玩,小狗转圈咬自己的尾巴 SpinWait是一个结构体,并不是一个类. ...

  10. 基于Haar特征的Adaboost级联人脸检测分类器

    基于Haar特征的Adaboost级联人脸检测分类器基于Haar特征的Adaboost级联人脸检测分类器,简称haar分类器.通过这个算法的名字,我们可以看到这个算法其实包含了几个关键点:Haar特征 ...