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 ...
随机推荐
- Select2 4.0.5 API
详细属性参考官方API,https://github.com/select2/select2/releases/tag/4.0.5 注:4.0.5版本API与3.x版本有差异,有些属性已废弃,以下列出 ...
- 下拉框、下拉控件之Select2
一.Select2的功能简介 select2插件给我们带来了更加友好的交互方式,比如查询控件展开后可通过关键字进行检索 例如: Select2也可以选择带查询控件的选择框... Select2也可以选 ...
- MySQL Connector/ODBC 2.50 (MyODBC 2.50)连接方式
一.MySQL Connector/ODBC 2.50 (MyODBC 2.50)连接方式 1.本地数据库连接Driver={MySQL};Server=localhost;Option=16834; ...
- Socket和ObjectOutputStream问题
用到Socket序列化对象网络传输时ObjectOutputStream一直刷新连接 用户代码 package com.jachs.ladflower.ladflower; import java.n ...
- socket FTP-1
基于socket实现文件的传输以及md5验证 server: import socket import os import hashlib server=socket.socket() server. ...
- 【转】解决Maxwell发送Kafka消息数据倾斜问题
最近用Maxwell解析MySQL的Binlog,发送到Kafka进行处理,测试的时候发现一个问题,就是Kafka的Offset严重倾斜,三个partition,其中一个的offset已经快200万了 ...
- elasticsearch介绍,安装,安装错误解决及相应插件安装
一.elasticsearch介绍 1.简介(使用的是nosql,更新比mongodb慢): ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎, ...
- app自动化测试Appium+python
一.node.js安装 https://nodejs.org/en/download/ ##一直下一步 ###cmd查看 二. .NET Framework安装 https://www.micros ...
- The Bug and Exception of Hibernate
1: hibernate4.3.5 的@oneToOne注解有Bug,建议不使用该版本,或者使用该版本不使用@table annotation. 2:今天在用hibernate4.2.13的时候, ...
- FMC
FMC (FPGA Mezzanine Card) 编辑 FMC:英文全称,FPGA Mezzanine Card.是一个应用范围.适应环境范围和市场领域范围都很广的通用模块.FMC连接器(FMC C ...