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; 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

  1. #include<iostream> //海星
  2. #include<unordered_map>
  3. #include<string>
  4. #include<vector>
  5. #include<algorithm>
  6. using namespace std;
  7. struct node{
  8. string code;
  9. int n, tws=0;
  10. int s[3]={0};
  11. node(string c):code(c), n(1), tws(0){
  12. }
  13. };
  14. unordered_map<string, int> m;
  15. bool cmp(const node& a, const node& b){
  16. if(a.tws!=b.tws) return a.tws>b.tws;
  17. else if(a.n!=b.n) return a.n<b.n;
  18. else return a.code<b.code;
  19. }
  20. int main(){
  21. int n, cnt=1;
  22. cin>>n;
  23. vector<node> v;
  24. for(int i=0; i<n; i++){
  25. string id, code;
  26. int s, t;
  27. cin>>id>>s>>code;
  28. for(int j=0; j<code.size(); j++)
  29. code[j]=tolower(code[j]);
  30. if(id[0]=='B') t=0;
  31. else if(id[0]=='A') t=1;
  32. else t=2;
  33. if(m[code]==0){
  34. node temp(code);
  35. temp.s[t]=s;
  36. v.push_back(temp);
  37. m[code]=cnt;
  38. cnt++;
  39. }else{
  40. v[m[code]-1].n++;
  41. v[m[code]-1].s[t]+=s;
  42. }
  43. }
  44. for(int i=0; i<v.size(); i++)
  45. v[i].tws=v[i].s[0]/1.5+v[i].s[1]+v[i].s[2]*1.5;
  46. sort(v.begin(), v.end(), cmp);
  47. cout<<v.size()<<endl;
  48. int lastrank=1;
  49. cout<<1<<" "<<v[0].code<<" "<<v[0].tws<<" "<<v[0].n<<endl;
  50. for(int i=1; i<v.size(); i++){
  51. if(v[i].tws!=v[i-1].tws)
  52. lastrank=i+1;
  53. cout<<lastrank<<" "<<v[i].code<<" "<<v[i].tws<<" "<<v[i].n<<endl;
  54. }
  55. return 0;
  56. }

PAT 1141 PAT Ranking of Institutions的更多相关文章

  1. [PAT] 1141 PAT Ranking of Institutions(25 分)

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  2. 1141 PAT Ranking of Institutions[难]

    1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...

  3. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  4. 1141 PAT Ranking of Institutions (25 分)

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  5. A1141. PAT Ranking of Institutions

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  6. PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  7. PAT_A1141#PAT Ranking of Institutions

    Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...

  8. PAT甲级1141 Ranking of Institutions

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 题意: 给定几个学生的PAT分数和学校 ...

  9. 1141 PAT Ranking of Institutions

    题意:给出考生id(分为乙级.甲级和顶级),取得的分数和所属学校.计算各个学校的所有考生的带权总成绩,以及各个学校的考生人数.最后对学校进行排名. 思路:本题的研究对象是学校,而不是考生!因此,建立学 ...

随机推荐

  1. 【149】ArcGIS Desktop 10.0 & Engine 10.0 安装及破解

    写在前面:可能会出现按照此方法无法破解的情况,那请确保您有将 ArcGIS 10.0 已经完全卸载干净,直接通过控制面板进行卸载的时候并不能将其卸载干净,需要进行更深层次的卸载,包括删除注册表,各种文 ...

  2. oracle创建默认表空间---重要

    当oracle创建数据库后,sys创建用户时还要有默认表空间.不创建默认表空间在导如项目时会有些数据表导入不成功! 由于时间仓促以截屏为例  之后会在刚刚那个空文件生成一个文件 ----------- ...

  3. Python网咯爬虫 — Scrapy框架应用

    Scrapy框架       Scrapy是一个高级的爬虫框架,它不仅包括了爬虫的特征,还可以方便地将爬虫数据保存到CSV.Json等文件中.       Scrapy用途广泛,可以用于数据挖掘.监测 ...

  4. H5页面背景音乐,C33 360°旋转效果

    在做H5页面的时候,经常会需要用到背景音乐,比如电子贺卡.动态音乐相册等,右上角有个360°旋转的音乐图标,点击可以控制音乐是否播放,那这个效果是如何实现的呢?我现整理了一下代码:  Demo  点击 ...

  5. 洛谷P4397 [JLOI2014]聪明的燕姿

    传送门 dfs的时候莫名其妙深度太大过不了……然后死活找不出哪里错…… 首先,约数和这东西是个积性函数,或者直接点的话就是如果$$n=p_1^{a_1}p_2^{a_2}p_3^{a_3}…p_m^{ ...

  6. mysql timeout expired处理

    一.发现问题 二.分析问题 .net长时间连接mysql导致超时: 方式一:连接用完后,就关闭连接 方式二:增加C#的执行sqlcommand时间 三.解决问题 增加了这一句,问题解决了 using ...

  7. 网上商城 Incorrect datetime value: '' for column 'ordertime' at row 1

    今天在做商城项目的[提交订单]功能的时候,向数据库插入数据报错:Incorrect datetime value: '' for column 'ordertime' at row 1 public ...

  8. html5 页面音频

    1. html5 样式 <audio class="audioleft download" id="audVoice" type="audio/ ...

  9. JBoss4.2的启动方式-Jboss无法通过IP地址访问,只能用localhost访问

    JBOSS版本:4.2.3GA症状:服务器无法通过IP地址去访问,只能用127.0.0.1或者localhost来访问. 开始怀疑是端口没有放开,用telnet ip 80 也不能连接,就一直怀疑端口 ...

  10. dutacm.club_1087_Common Substrings_(KMP)_(结合此题通俗理解kmp的next数组)

    1087: Common Substrings Time Limit:3000/1000 MS (Java/Others)   Memory Limit:163840/131072 KB (Java/ ...