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. mybatis事务管理机制详解

    1.mybatis事务的配置和使用 mybatis事务有两种使用方式: (a):使用JDBC的事务管理机制:即使用java.Sql.Connection对象完成对事务的提交,回滚和关闭操作. (b): ...

  2. 运行Spark-shell,解决Unable to load native-hadoop library for your platform

    启动spark后,运行bin/spark-shell会出现一个警告 提君博客原创 WARN util.NativeCodeLoader: Unable to load native-hadoop li ...

  3. C# Note34: 异常机制相关小点

    1.使用throw和throw ex抛出异常的区别 通常,我们使用try/catch/finally语句块来捕获异常,那么在抛出异常的时候,使用throw和throw ex有什么区别呢? 假如,按顺序 ...

  4. Spark join连接

    内链接

  5. asyncio并发编程

    一. 事件循环 1.注: 实现搭配:事件循环+回调(驱动生成器[协程])+epoll(IO多路复用),asyncio是Python用于解决异步编程的一整套解决方案: 基于asynico:tornado ...

  6. 记一次tomcat7.0版本启动项目失败问题

    测试项目在tomcat7中启动失败,报错如下: @794314bc3 Error during job execution (jobs.Bootstrap) Oops: VerifyError ~ p ...

  7. 莫烦scikit-learn学习自修第一天【scikit-learn安装】

    1. 机器学习的分类 (1)有监督学习(包括分类和回归) (2)无监督学习(包括聚类) (3)强化学习 2. 安装 (1)安装python (2)安装numpy >=1.6.1 (3)安装sci ...

  8. PHPCMS的使用

    1.下载安装phpcms 下载完后解压将install_packages上传到服务器并重命名为phpcms_test: 更改目录文件系统权限: chmod -R 777 phpcms_test 配置n ...

  9. pip 安装 MySQL-python 报错

    报错一:EnvironmentError: mysql_config not found 解决:yum install mysql-devel 报错二:Python.h No such file or ...

  10. delphi怎样在关闭程序时弹出窗口?

    我想在关闭delphi编译的程序时,弹出“您是否确实要退出的窗口”点击否不退出,是退出 在主窗体的CloseQuery事件里,使用messagebox进行提示,根据选择的按钮对Canclose进行设置 ...