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 ;
}

A1141. PAT Ranking of Institutions的更多相关文章

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

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

  2. PAT_A1141#PAT Ranking of Institutions

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

  3. 1141 PAT Ranking of Institutions[难]

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

  4. PAT 甲级 1141 PAT Ranking of Institutions

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

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

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

  6. 1141 PAT Ranking of Institutions (25 分)

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

  7. PAT 1141 PAT Ranking of Institutions

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

  8. 1141 PAT Ranking of Institutions

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

  9. PAT Ranking (排名)

    PAT Ranking (排名) Programming Ability Test (PAT) is organized by the College of Computer Science and ...

随机推荐

  1. jQuery-mobilevalidate使用 的一些心得,小小总结

    在做M站时比较纠结的是表单验证,不像pc端,移动端的验证要求插件更小更轻量,更加灵活,说不定是冒气泡的报错提示?! 介绍一款好用的移动端的表单验证插件:jQuery-mobilevalidate: 代 ...

  2. windos安装maven

    1.下载好maven压缩包,并解压到相应位置,本次安装在D: 2.配置环境变量 MAVEN_HOME=D:\apache-maven-3.0.5 path=%MAVEN_HOME% 3.生成maven ...

  3. python学习笔记(5-1)-基本数据类型-字符串类型及操作

    五.字符串处理函数  len(x):字符串x的长度.如len("12345")结果为5  str(x):任意类型x所对应的字符串形式. >>> str(123) ...

  4. docker学习笔记一

    知识点: 1)docker简介 2)docker安装,仓库配置 3)docker仓库镜像拉取,导出,导入,删除 4)docker容器操作,容器的创建,删除,运行,停止,日志查看等. 5)  docke ...

  5. Cisco IP 电话 将它的voice mail 发送到手机

    功能一.将语音转成文字发送短信(有微软认知.百度认知.云片短信API) 功能二.直接将音频发送到微信 不废话,直接送个包 链接: https://github.com/JaviZhu/KLCN.Spe ...

  6. ASP.NET MVC和Web API中的Angular2 - 第1部分

    下载源码 - 903.5 KB 内容 第1部分:Visual Studio 2017中的Angular2设置,基本CRUD应用程序,第三方模态弹出控件 第2部分:使用Angular2管道进行过滤/搜索 ...

  7. hibernate主配置文件中指定session与当前线程绑定

    配置一条属性 <property name="hibernate.current_session_context_class">thread</property& ...

  8. AMD三代锐龙箭在弦上:如此家族堪称豪华

    AMD将于今年年中正式推出第三代Ryzen锐龙处理器,即不集成显示芯片的纯CPU产品,外界猜测可能的时间点会是5月底的台北电脑展. 虽说依然采用AM4接口,也就是X370/470老主板可无压力兼容,但 ...

  9. form-layui

    html <div id="formData"> <form class="layui-form formBtn" style="m ...

  10. shiro注解和标签

    Controller中注解: @RequiresAuthentication @RequiresGuest @RequiresPermissions("account:create" ...