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. CMakefile for Cross-Platform Compling - 1

    cmake可以自动侦测目标系统,通常编译时候包含的文件和链接的库都不是本地的文件. Demo #toolchain cmake file SET(CMAKE_SYSTEM_NAME Linux) SE ...

  2. 数字图像处理实验(16):PROJECT 06-03,Color Image Enhancement by Histogram Processing 标签: 图像处理MATLAB 2017

    实验要求: Objective: To know how to implement image enhancement for color images by histogram processing ...

  3. [GO]copy的使用

    package main import "fmt" func main() { srcslice := [],} dstslice := [],,,,,} copy(dstslic ...

  4. Qt工程文件Pro介绍(转)

    转载请注明:http://blog.163.com/hu_cuit/blog/static/122849143201127104232142/ 我也才开始学习QT的菜鸟.但是前几天有同学叫我给他讲一下 ...

  5. xml解析中的DOM和SAX的区别

    面试题:DMO和SAX的区别? DOM解析的优点:增删查改操作方便,缺点:占用内存较大,不适合解析大的XML文件: SAX解析的优点:占用内存小,解析快:缺点:不适合增删查改:

  6. wpf path语法

    http://www.cnblogs.com/HQFZ/p/4452548.html WPF系列 Path表示语法详解(Path之Data属性语法)

  7. Spring:配置文件

    首先是bean.xml,配置所有的bean,一般也叫applicationContext.xml,应用程序上下文.示例: <?xml version="1.0" encodi ...

  8. GetPixelAddress()函数Alpha通道会丢失

    CImage类中GetPixelAddress()函数来设置获取对应的颜色值是发现Alpha无效. void CGBImage::Load(){ CImage sourceImage; sourceI ...

  9. cocos学习

    第一章 JavaScript 快速入门 1.1 变量 在 JavaScript 中,我们像这样声明一个变量: var a; 保留字 var 之后紧跟着的,就是一个变量名,接下来我们可以为变量赋值: v ...

  10. ASP.Net UpdatePanel控件 局部刷新 && 弹出提示信息

    参考博客: https://blog.csdn.net/qq_35019337/article/details/69972552 https://blog.csdn.net/huangyezi/art ...