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. c语言实践输出某个区间中不是3的倍数的偶数

    OK,先审题,我们最后要输出的那些数是需要满足两个条件的,第一个条件是,这个数不是3的倍数,第二个条件是这个数是偶数.也就是这样的数需要同时满足这两个条件的时候才把这个数输出. 不是3的倍数这个条件在 ...

  2. WordCountPro

    github项目地址:https://github.com/Hoyifei/SQ-T-Homework-WordCount-Advanced PSP表格   PSP2.1 PSP阶段 预估耗时 (分钟 ...

  3. VMWare、Ubuntu Server 18.04 共享文件夹

    背景:VMWare选项中配置了共享文件夹,装完Ubuntu Server 18.04在 /mnt/下都没有 hgfs文件夹,更别提共享文件夹了 参考:Ubuntu16.04版安装VMwareTools ...

  4. 利用Thread.stop完成方法执行超时中断

    示例代码可以从github上获取 https://github.com/git-simm/simm-framework.git 接上篇博客<FutureTask子线程取消执行的状态判断> ...

  5. 好的linux网站

    site:www.tldp.org rpm http://www.computerhope.com/unix.htm

  6. iOS play video

    iOS: How to use MPMoviePlayerController up vote6down votefavorite 3 I've created a blank project (iO ...

  7. 三羊献瑞——第六届蓝桥杯C语言B组(省赛)第三题

    原创 三羊献瑞 观察下面的加法算式: 祥 瑞 生 辉 + 三 羊 献 瑞 ------------------- 三 羊 生 瑞 气 (如果有对齐问题,可以参看[图1.jpg]) 其中,相同的汉字代表 ...

  8. EBS登陆界面个性化

    把完整资料贴出来 Set the profile option Local Login Mask (FND_SSO_LOCAL_LOGIN_MASK). (This profile option is ...

  9. VSCode调试设置

    tasks.json { "version": "0.1.0", "isShellCommand": true, "args&qu ...

  10. 自建脚手架之配置中心--LightConf的实现

    常规项目开发过程中, 通常会将配置信息位于在项目resource目录下的properties文件文件中, 配置信息通常包括有: jdbc地址配置.redis地址配置.活动开关--等等.因此每次上线或者 ...