PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184
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 <bits/stdc++.h>
- using namespace std;
- const int maxn = 1e5 + 10;
- int N;
- map<string, int> mp;
- string lowercase(string c) {
- string ans = "";
- int len = c.length();
- for(int i = 0; i < len; i ++) {
- if(c[i] >= 'A' && c[i] <= 'Z')
- ans += (c[i] + 32);
- else ans += c[i];
- }
- return ans;
- }
- struct Node{
- int st;
- int num;
- double score = 0;
- string name;
- }node[maxn];
- bool cmp(const Node &a, const Node &b) {
- if((int)a.score != (int)b.score)
- return (int)a.score > (int)b.score;
- else if((int)a.score == (int)b.score) {
- if(a.num != b.num)
- return a.num < b.num;
- else return a.name < b.name;
- }
- }
- int main() {
- scanf("%d", &N);
- mp.clear();
- int cnt = 0;
- while(N --) {
- char s[10]; int x; string namee;
- scanf("%s%d", s, &x);
- cin >> namee;
- namee = lowercase(namee);
- if(mp[namee] == 0) {
- cnt ++;
- mp[namee] = cnt;
- }
- node[mp[namee]].num ++;
- node[mp[namee]].name = namee;
- if(s[0] == 'B') node[mp[namee]].score += (2.0 * x / 3);
- else if(s[0] == 'A') node[mp[namee]].score += 1.0 * x;
- else if(s[0] == 'T') node[mp[namee]].score += (3.0 * x / 2);
- }
- sort(node + 1, node + 1 + cnt, cmp);
- cout << cnt << endl;
- node[1].st = 1;
- cout << node[1].st << " " << node[1].name << " " << (int)node[1].score << " " << node[1].num << endl;
- for(int i = 2; i <= cnt; i ++) {
- if((int)node[i].score == (int)node[i - 1].score)
- node[i].st = node[i - 1].st;
- else node[i].st = i;
- cout << node[i].st << " " << node[i].name << " " << (int)node[i].score << " " << node[i].num << endl;
- }
- return 0;
- }
第一次交最后一个测试点没过 要用 double 算 score 然后强制类型转换 (int)
FHFHFH
PAT 甲级 1141 PAT Ranking of Institutions的更多相关文章
- PAT甲级1141 Ranking of Institutions
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 题意: 给定几个学生的PAT分数和学校 ...
- PAT 甲级 1025 PAT Ranking
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- PAT甲级——1025 PAT Ranking
1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...
- PAT 甲级 1025.PAT Ranking C++/Java
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...
- PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)
题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...
- PAT甲级——A1025 PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...
- PAT甲级1075 PAT Judge
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT甲级——A1075 PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
随机推荐
- # 20155207王雪纯 实验一 逆向与Bof基础
20155207王雪纯 实验一 逆向与Bof基础 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字 ...
- 20155210 潘滢昊2016-2017-2 《Java程序设计》第9周学习总结
20155210 2016-2017-2 <Java程序设计>第9周学习总结 教材学习内容总结 JDBC驱动的四种类型(按操作方式分类的): JDBC-ODBC Bridge Driver ...
- Codeforces 937 D. Sleepy Game(DFS 判断环)
题目链接: Sleepy Game 题意: Petya and Vasya 在玩移动旗子的游戏, 谁不能移动就输了. Vasya在订移动计划的时候睡着了, 然后Petya 就想趁着Vasya睡着的时候 ...
- 洛谷 P4478 [BJWC2018]上学路线
洛谷 P4478 [BJWC2018]上学路线 原题 神仙题orz,竟然没有1A....容斥+卢卡斯+crt?? 首先用容斥做,记\(f[i][0/1]\)表示到i号点经过了奇数/偶数个点的方案数,因 ...
- TCP协议的特点
tcp 面向连接,三次握手,创建会话:双向的关闭tcp 可靠性,具备传输确认机制,接收端会对接收到的数据进行ack确认;tcp 具备 rtt (raund动态估算传输时间;tcp 具备超时重传机制tc ...
- CentOS安装Zabbix Agent
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm安装存储库 yum ...
- [Unity Shader] 逐顶点光照和逐片元漫反射光照
书中的6.4节讲的是漫反射的逐顶点光照和逐片元光照. 前一种算法是根据漫反射公式计算顶点颜色(顶点着色器),对颜色插值(光栅化过程)返回每个像素的颜色值(片元着色器). 第二种算法是获得顶点的法线(顶 ...
- 用UGUI制作可根据手指位置自动定位的隐形遥杆
之前写过遥杆怎么做,这里依然用的是之前的方法,就不介绍了. 之前玩过<蜡烛人>,发现手游版的<蜡烛人>的遥杆是看不见的,手指直接在屏幕左边滑动人物就可以移动,可能是为了增强沉浸 ...
- JavaScript判断对象是否是NULL(转)
写js经常会遇到非空判断,看了你不就像风一样的文章 自己没有做总结,特地转载.很有帮助 function isEmpty(obj) { // 检验 undefined 和 null if (!obj ...
- java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
RabbitMq配置时常见错误 java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper <de ...