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 ...
随机推荐
- Service和IntentService的区别
不知道大家有没有和我一样,以前做项目或者练习的时候一直都是用Service来处理后台耗时操作,却很少注意到还有个IntentService,前段时间准备面试的时候看到了一篇关于IntentServic ...
- Palindromeness CodeChef - PALPROB
传送门 分析 有中文题面所以就不写题目大意了 我们先建出回文树 然后根据fail信息建出一棵树 从根向下dfs,中间记录每一个len出现在哪个节点即可 代码 #include<iostream& ...
- 利用osmosis导出osm城市数据
转载(未测试) 方法核心就是利用osmosis的导出指定功能,即是从大范围导出小范围的基本用例. 我们只需要知道我们所需要提取的城市的经纬度范围, 例如广州市的经纬度范围是北纬22.26~23.56度 ...
- 如何实现字符串的翻转,不用php库函数翻转字符串
- php抓取网页中的内容
以下就是几种常用的用php抓取网页中的内容的方法.1.file_get_contentsPHP代码代码如下:>>>>>>>>>>>&g ...
- HDU 6047 Maximum Sequence (贪心+单调队列)
题意:给定一个序列,让你构造出一个序列,满足条件,且最大.条件是 选取一个ai <= max{a[b[j], j]-j} 析:贪心,贪心策略就是先尽量产生大的,所以就是对于B序列尽量从头开始,由 ...
- js工具库简单介绍
javascript mvc的解决方案: angularjs, backbone,underscore, 有空的时候了解一下. 移动端的几个需要了解一下,jq mobile, zepto.knocko ...
- 一个数组:1,1,2,3,5,8,13,21...+m,求第30位数是多少?用递归实现;(常考!!!)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- ajax 判断账户密码 调取数据模糊查询 时钟
一.判断账户密码 <Login.html> <head> <meta http-equiv="Content-Type" content=" ...
- 查看服务器的ip地址
因测试需要查看服务器的ip地址,故进行搜索. 1.(操作成功的方法)在浏览器输入www.ip.cn,可查询出ip地址: 2.(说明书的操作方法,但我未能查询到ip地址)在浏览器输入http://ip. ...