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; 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 <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 ...
随机推荐
- Entity Framework 多对多查询的写法
同学们,看下面的代码段就明白了: 一对多: public ICollection<ReportLookup> GetReportLookup(IEnumerable<Guid> ...
- [二进制trie][贪心]CSUOJ1216异或最大值
题目传送门 过了好久,终于重新开始写博客了... 这是一道二进制trie树的模板题. 二进制trie树,理解一下就是一颗二叉树,左右儿子为0或1. 然后每插入一个数就进行一次Find操作. Find: ...
- UOJ UR#9 App管理器
题目传送门 题目大意大概就是给你一个混合图(既有有向边又有无向边),对于每条无向边,u-v,问删去u->v,或删去v->u那条可以使新图强连通.(保证数据有解). 这道题前几个数据点送分. ...
- 成都Uber优步司机奖励政策(4月21日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 关于DP和背包
听说过动态规划(DP)的同学应该都知道有背包问题的存在. 首先我们来了解一下动态规划 基本思想: 动态规划算法通常用于求解具有某种最优性质的问题. 在这类问题中, 可能会有很多可行解.每一个解都对应于 ...
- 【bzoj1066】【luogu2472】[SCOI2007]蜥蜴
1066: [SCOI2007]蜥蜴 Time Limit: 1 Sec Memory Limit: 162 MB Description 在一个r行c列的网格地图中有一些高度不同的石柱,一些石柱上 ...
- check the manual that corresponds to your MySQL server version for the right syntax to use near
一.问题 mysql插入数据时报错 sql如下 insert into t_sysconfig (servercode,key,value,remark,updatetime) values (&qu ...
- arduino八段数码管使用
一:八段数码管的使用 控制要求:0-9的计时数据 实物连接图: 控制代码: //智慧自动化2018.6.11 ;//定义数字接口7 连接a 段数码管 ;// 定义数字接口6 连接b 段数码管 ;// ...
- Selenium+Python自动化测试学习问题总结笔记
1.问题描述:不能导入自定义类 错误内容:This inspection detects names that should resolve but don't. Due to dynamic dis ...
- 理解unittest(六)
unittest,顾名思义就是一个单元测试框架,但是它不仅适用于单元测试,还适用WEB自动化测试用例的开发与执行,该测试框架可组织执行测试用例,并且提供了丰富的断言方法,判断测试用例是否通过,最终生成 ...