题意:

输入两个整数N,M(<=2000),接着分别输入N个学生的ID,C语言成绩,数学成绩和英语成绩。

M次询问,每次输入学生ID,如果该ID不存在则输出N/A,存在则输出该学生排名最考前的一门成绩的名次和课程编号。优先级:A>C>M>E。A代表CMD三门课的平均成绩(操作时可用总成绩来替代平均成绩处理)。

trick:

成绩相同时将其名次合并(多个学生并列)

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
string s[];
int c[],m[],e[],a[];
pair<int,int>cc[],mm[],ee[],aa[];
int rak[],rak_c[],rak_m[],rak_e[],rak_a[];
char ans[];
map<string,int>mp;
bool cmp(pair<int,int>a,pair<int,int>b){
return a.first>b.first;
}
int main(){
int n,q;
cin>>n>>q;
for(int i=;i<=n;++i){
cin>>s[i]>>c[i]>>m[i]>>e[i];
a[i]=c[i]+m[i]+e[i];
cc[i].first=c[i];
cc[i].second=i;
mm[i].first=m[i];
mm[i].second=i;
ee[i].first=e[i];
ee[i].second=i;
aa[i].first=a[i];
aa[i].second=i;
mp[s[i]]=i;
}
sort(cc+,cc++n,cmp);
sort(mm+,mm++n,cmp);
sort(ee+,ee++n,cmp);
sort(aa+,aa++n,cmp);
for(int i=;i<=n;++i){
rak_c[i]=i;
if(cc[i].first==cc[i-].first)
rak_c[i]=rak_c[i-];
rak_m[i]=i;
if(mm[i].first==mm[i-].first)
rak_m[i]=rak_m[i-];
rak_e[i]=i;
if(ee[i].first==ee[i-].first)
rak_e[i]=rak_e[i-];
rak_a[i]=i;
if(aa[i].first==aa[i-].first)
rak_a[i]=rak_a[i-];
}
for(int i=;i<=n;++i){
rak[aa[i].second]=rak_a[i];
ans[aa[i].second]='A';
}
for(int i=;i<=n;++i)
if(rak_c[i]<rak[cc[i].second]){
rak[cc[i].second]=rak_c[i];
ans[cc[i].second]='C';
}
for(int i=;i<=n;++i)
if(rak_m[i]<rak[mm[i].second]){
rak[mm[i].second]=rak_m[i];
ans[mm[i].second]='M';
}
for(int i=;i<=n;++i)
if(rak_e[i]<rak[ee[i].second]){
rak[ee[i].second]=rak_e[i];
ans[ee[i].second]='E';
}
string quy;
for(int i=;i<=q;++i){
cin>>quy;
if(!mp[quy])
cout<<"N/A"<<"\n";
else
cout<<rak[mp[quy]]<<" "<<ans[mp[quy]]<<"\n";
}
return ;
}

【PAT甲级】1012 The Best Rank (25 分)的更多相关文章

  1. PAT 甲级 1012 The Best Rank (25 分)(结构体排序)

    题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同时,我们鼓励学生强调自己的最优秀队伍 - 也就是说 ...

  2. PAT甲级1012. The Best Rank

    PAT甲级1012. The Best Rank 题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同 ...

  3. 1012 The Best Rank (25分) vector与结构体排序

    1012 The Best Rank (25分)   To evaluate the performance of our first year CS majored students, we con ...

  4. PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  5. PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

    1062 Talent and Virtue (25 分)   About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...

  6. PAT 甲级 1056 Mice and Rice (25 分) (队列,读不懂题,读懂了一遍过)

    1056 Mice and Rice (25 分)   Mice and Rice is the name of a programming contest in which each program ...

  7. PAT 甲级 1040 Longest Symmetric String (25 分)(字符串最长对称字串,遍历)

    1040 Longest Symmetric String (25 分)   Given a string, you are supposed to output the length of the ...

  8. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  9. PAT甲级——1130 Infix Expression (25 分)

    1130 Infix Expression (25 分)(找规律.中序遍历) 我是先在CSDN上面发表的这篇文章https://blog.csdn.net/weixin_44385565/articl ...

  10. PAT 甲级 1074 Reversing Linked List (25 分)(链表部分逆置,结合使用双端队列和栈,其实使用vector更简单呐)

    1074 Reversing Linked List (25 分)   Given a constant K and a singly linked list L, you are supposed ...

随机推荐

  1. Android Studio真机无线调试

    条件 手机要和电脑处于同一局域网内(即都连同一个WiFi 或者电脑的网线另外一段连接到手机连接WiFi的路由上) 步骤 .首先将手机连接 WiFi 网络 .将手机用数据线与电脑连接,并且在电脑端 打开 ...

  2. RedHat7.0 网络源的配置

    RedHat7.0 yum源的配置 写这篇随笔的目的 为了记录自己的操作,能够为以后的再次配置提供参考 因为网上的教程都有些年代了,为了方便其他同学方便配置 提高下自己的写作水平 参考资料 RedHa ...

  3. 吴裕雄 人工智能 java、javascript、HTML5、python、oracle ——智能医疗系统WEB端智能分诊代码简洁版实现

    <%-- Document : getInfo Created on : 2018-10-7, 21:36:37 Author : acer --%> <%@page import= ...

  4. Booth算法: 补码一位乘法公式推导与解析

    以下讲解内容出自<计算机组成原理(第三版)>(清华大学出版社) 大二学生一只,我的计组老师比较划水,不讲公式推导,所以最近自己研究了下Booth算法的公式推导,希望能让同样在研究Booth ...

  5. Python - for循环的本质,迭代器,可迭代对象

    参考 https://foofish.net/how-for-works-in-python.html for循环可以迭代一个可迭代(iterable)的对象 原理 生成这个可迭代对象(实现了__it ...

  6. Webflux是什么东东

    转自:百家号-薇薇心语 各位Javaer们,大家都在用SpringMVC吧?当我们不亦乐乎的用着SpringMVC框架的时候,Spring5.x又悄(da)无(zhang)声(qi)息(gu)的推出了 ...

  7. 【代码总结】GD库中简单的验证码

    大体思路: 代码部分: <?php //1.创建画布 $img = imagecreatetruecolor(100,30); //2.设置颜色 值越小,颜色越深 $color1 = image ...

  8. 吴裕雄 PYTHON 神经网络——TENSORFLOW MNIST读取数据

    from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("E ...

  9. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  10. ASA-有关AAA用户登录的问题

    问题示例:I have created a test user that is set to privilege 15 in the config: When I log in to the ASA ...