1141 PAT Ranking of Institutions (25 分)
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 (≤105), 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 分)的更多相关文章
- 1141 PAT Ranking of Institutions[难]
1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...
- [PAT] 1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- PAT 1141 PAT Ranking of Institutions
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- 1141 PAT Ranking of Institutions
题意:给出考生id(分为乙级.甲级和顶级),取得的分数和所属学校.计算各个学校的所有考生的带权总成绩,以及各个学校的考生人数.最后对学校进行排名. 思路:本题的研究对象是学校,而不是考生!因此,建立学 ...
- PAT_A1141#PAT Ranking of Institutions
Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...
- PTA PAT排名汇总(25 分)
PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...
- PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- A1141. PAT Ranking of Institutions
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
随机推荐
- OpenGL绘图框架(GLFW)
下载地址:http://www.glfw.org/download.html
- 在MYSQL中运用全文索引(FULLTEXT index)
在MYSQL中使用全文索引(FULLTEXT index) MYSQL的一个很有用的特性是使用全文索引(FULLTEXT index)查找文本的能力.目前只有使用MyISAM类型表的时候有效(MyIS ...
- 见过最好的mybatis学习网站
http://blog.csdn.net/techbirds_bao/article/details/9233599/
- spring的一些配置和重要的接口和类
spring的配置文件 通常是applicationContext.xml(具体的bean配置会在后面内容中详解) setter方法注入: <property name=“” value=“ja ...
- Linux中的SELinux与chcon以及Samba实现【转】
一.SELinux SElinux的前身是NSA(美国国家安全局)发起的一个项目.它的目的是将系统加固到可以达到军方级别. 为什么NSA选择Linux呢? 在目前市面上大多数操作系统都是商用闭源的,只 ...
- Graphics 小记
1.切图 drowg.DrawImage(productImg1, new System.Drawing.Rectangle(30, 30, 300, 300), new System.Drawing ...
- React 使用browserHistory项目访问404问题
最近项目里面用到了React但是发布到iis站点之后,路由地址 刷新访问直接404错误.查阅资料之后发现是iis缺少配置URL重写 的问题导致的.下面我们来图形化配置,简单的配置下IIS 打开IIS使 ...
- 复制构造函数被调用的三种情况------新标准c++程序设计
1.当用一个对象去初始化同类的另一个对象时,会引发复制构造函数被调用.例如,下面的两条语句都会引发复制构造函数的调用,用以初始化c2. C c2 (c1); C c2=c1; 这两条语句是等价的.注意 ...
- 查看Eclipse版本号的方法及各个版本区别 Eclipse选择标准
这篇文章主要介绍了查看Eclipse版本号的方法及各个版本区别 Eclipse选择标准,方便初学者选择适合自己的版本,需要的朋友可以参考下 Eclipse 是一个开放源代码的.基于Java的可扩展开发 ...
- 题解 P2350 【[HAOI2012]外星人】
题目链接 还是本宝宝写题解的一贯习惯 $ :$ 先吐槽吐槽这道题$……$ 相信不少同学第一眼一定没有看懂题.(因为我也没看懂) ~~初中~~数学知识: 对于函数 $ f(x)$ 有 $f^{-1}(x ...