A1141. PAT Ranking of Institutions
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的更多相关文章
- PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- PAT_A1141#PAT Ranking of Institutions
Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...
- 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
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- [PAT] 1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- 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
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- 1141 PAT Ranking of Institutions
题意:给出考生id(分为乙级.甲级和顶级),取得的分数和所属学校.计算各个学校的所有考生的带权总成绩,以及各个学校的考生人数.最后对学校进行排名. 思路:本题的研究对象是学校,而不是考生!因此,建立学 ...
- PAT Ranking (排名)
PAT Ranking (排名) Programming Ability Test (PAT) is organized by the College of Computer Science and ...
随机推荐
- 设计模式之原型模式(c++)
问题描述 看到这个模式,很容易想到小时候看的<西游记>,齐天大圣孙悟空发飙的时候可以通过自己头上的 3 根毛立马复制出来成千上万的孙悟空, 对付小妖怪很管用(数量最重要). Prototy ...
- JAVA不可变类(immutable)机制与String的不可变性--非常好.
JAVA不可变类(immutable)机制与String的不可变性 https://www.cnblogs.com/jaylon/p/5721571.html
- PLSQL 汉化
自动导入PLSQL安装目录: 一直下一步就可以了: 之后重新打开:
- MIUI(ADUI)关闭广告推送步骤方法
MIUI自从到了版本MIUI8之后,系统增加了各种推送,让人们所诟病.很多消费者因为这个原因,不再考虑小米手机,尽管小米手机确实很便宜. 下面就说一下如何关闭所有的MIUI 8的广告推送.方法源自MI ...
- How to enable flash on Chromium
sudo apt install chromium-browser pepperflashplugin-nonfree
- 2.ansible-playbook基本参数
ansible-playbook的参数--force-handlers run handlers even if a task fails 强制执行handler--list-tags list al ...
- Windows Server 2012 IIS 8 - 安装SSL证书
从证书邮件里或者用户中心复制对应的SSL证书文件代码 把代码粘贴到TXT文本文件里面 然后另存为cer或是crt文件,注意编码为ANSI 中级证书和交叉证书也是按以上方法保存为crt或cer文件即可 ...
- hdu-5687(字典树)
题意:中文题: 解题思路:增加和查询就不说了,标准操作,就是删除操作:删除操作的时候,我们把给定字符串先在字典树中遍历一遍,然后算出这个字符串最后一个字符的出现次数,然后在遍历一遍,每个节点都减去这个 ...
- C++:如何正确的定义一个接口类
C++中如何定义接口类?首先给接口类下了定义:接口类应该是只提供方法声明,而自身不提供方法定义的抽象类.接口类自身不能实例化,接口类的方法定义/实现只能由接口类的子类来完成. 而对于C++,其接口类一 ...
- python之旅六【第七篇】面向对象
面向对象三大特性 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强... 面向对象编程 ...