PAT (Advanced Level) 1012. The Best Rank (25)
简单排序题。
注意:分数相同的人排名相同。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std; struct X
{
int k;
int id;
int f1,f2,f3,f4;
int r[];
}s[];
int n,m;
map<int,int>z; int get(int a,int b,int c)
{
double sum=1.0*a+1.0*b+1.0*c;
sum=sum/+0.5;
int res=(int)sum;
return res;
} bool cmp1(const X&a,const X&b){return a.f1>b.f1;}
bool cmp2(const X&a,const X&b){return a.f2>b.f2;}
bool cmp3(const X&a,const X&b){return a.f3>b.f3;}
bool cmp4(const X&a,const X&b){return a.f4>b.f4;}
bool cmp5(const X&a,const X&b){return a.k<b.k;} int main()
{
scanf("%d%d",&n,&m); z.clear();
for(int i=;i<=n;i++)
{
scanf("%d%d%d%d",&s[i].id,&s[i].f2,&s[i].f3,&s[i].f4);
s[i].f1=get(s[i].f2,s[i].f3,s[i].f4);
z[s[i].id]=i;
s[i].k=i;
} s[].f1=s[].f2=s[].f3=s[].f4=-; sort(s+,s++n,cmp1);
for(int i=;i<=n;i++)
{
if(s[i].f1==s[i-].f1) s[i].r[]=s[i-].r[];
else s[i].r[]=i;
} sort(s+,s++n,cmp2);
for(int i=;i<=n;i++)
{
if(s[i].f2==s[i-].f2) s[i].r[]=s[i-].r[];
else s[i].r[]=i;
} sort(s+,s++n,cmp3);
for(int i=;i<=n;i++)
{
if(s[i].f3==s[i-].f3) s[i].r[]=s[i-].r[];
else s[i].r[]=i;
} sort(s+,s++n,cmp4);
for(int i=;i<=n;i++)
{
if(s[i].f4==s[i-].f4) s[i].r[]=s[i-].r[];
else s[i].r[]=i;
} sort(s+,s++n,cmp5); for(int i=;i<=m;i++)
{
int id; scanf("%d",&id);
if(z[id]==) printf("N/A\n");
else
{
int Min=;
for(int j=;j<=;j++)
Min=min(Min,s[z[id]].r[j]);
for(int j=;j<=;j++)
{
if(s[z[id]].r[j]==Min)
{
printf("%d ",Min);
if(j==) printf("A\n");
if(j==) printf("C\n");
if(j==) printf("M\n");
if(j==) printf("E\n");
break;
}
}
}
}
return ;
}
PAT (Advanced Level) 1012. The Best Rank (25)的更多相关文章
- PTA (Advanced Level) 1012 The Best Rank
The Best Rank To evaluate the performance of our first year CS majored students, we consider their g ...
- PAT (Advanced Level) 1113. Integer Set Partition (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1110. Complete Binary Tree (25)
判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...
- PAT (Advanced Level) 1094. The Largest Generation (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT (Advanced Level) 1074. Reversing Linked List (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1062. Talent and Virtue (25)
简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...
- PAT (Advanced Level) 1060. Are They Equal (25)
模拟题.坑点较多. #include<iostream> #include<cstring> #include<cmath> #include<algorit ...
- PAT (Advanced Level) 1056. Mice and Rice (25)
简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...
- PAT (Advanced Level) 1052. Linked List Sorting (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- 【读书笔记】C Primer Plus ch.15位运算 示例程序15.1 整数转换成二进制字符串
正文: https://www.zybuluo.com/RayChen/note/595213
- 算法:1!+(1!+3!)+(1!+3!+5!) + ( 1! + 3! + 5! + 7! + 9!)+....+(1!+3!+5!+ ... + m!)
-(void)touchesBegan:(nonnull NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{ / ...
- .net获取根目录的方法集合
编写程序的时候,经常需要用的项目根目录.自己总结如下 .取得控制台应用程序的根目录方法 方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径 方法2. ...
- 关于Winform中的用户代理
问题描述: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 解释: 1. 应用程序版本“Mozilla ...
- linux 查看 cpu 和内存的命令 - top
1.查看内存,cpu ,当前进程task数目, 每个进程的cpu, 内存使用率, 用top 命令: 在这个页面,按 P,下面的进程排序,以cpu使用率降序排列. 按M,按内存使用率降序排列: 按N, ...
- php 数据库并发处理
在并行系统中并发问题永远不可忽视.尽管PHP语言原生没有提供多线程机制,那并不意味着所有的操作都是线程安全的.尤其是在操作诸如订单.支付等业务系统中,更需要注意操作数据库的并发问题. 接下来我通过一个 ...
- Oracle表和表数据恢复
Oracle数据库表及表数据的恢复 1. 表恢复 对误删的表,只要没有使用 purge 永久删除选项,那么基本上是能从 flashback table 区恢复回来的. 数据表和其中的数据都是可以恢复回 ...
- php取随机数 explode劫取字符串 时间定义随机数
php取随机数 <?phpfunction randomkeys($length){ $pattern='1234567890'; for($i=0;$i<$length;$i++) { ...
- 会话管理---Cookie与Session
会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 保存会话数据的两种技术:Cookie,Session Cookie是客户端技术, ...
- ==与equals()方法的不同
==比较分为两种情况:基本数据类型比较与引用数据类型比较 1.基本数据类型,根据基本数据类型的值是否相等来判断,相等则返回true,不相等则返回false.两端数据类型可以不同,如果转换后的数值相等, ...