简单排序题。

注意:分数相同的人排名相同。

#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)的更多相关文章

  1. 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 ...

  2. PAT (Advanced Level) 1113. Integer Set Partition (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  3. PAT (Advanced Level) 1110. Complete Binary Tree (25)

    判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...

  4. PAT (Advanced Level) 1094. The Largest Generation (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  5. PAT (Advanced Level) 1074. Reversing Linked List (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  6. PAT (Advanced Level) 1062. Talent and Virtue (25)

    简单排序.题意较长. #include<cstdio> #include<cstring> #include<cmath> #include<queue> ...

  7. PAT (Advanced Level) 1060. Are They Equal (25)

    模拟题.坑点较多. #include<iostream> #include<cstring> #include<cmath> #include<algorit ...

  8. PAT (Advanced Level) 1056. Mice and Rice (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  9. PAT (Advanced Level) 1052. Linked List Sorting (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. 获取IP地址bash[转载]

    ipaddr=`/sbin/ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d : -f2 | awk '{print $1}'`

  2. su -无反应

    一.问题产生环境 CentOS 6.3 X64SecureCRT 7.0.0 英文版 二.问题具体描述 今天操作自己的一台Linux服务器时,突然su命令不好使了,敲入命令回车后,没有任何反应,不管是 ...

  3. Django CRM学员系统项目

    项目需求: 1.分讲师\学员\课程顾问角色,2.学员可以属于多个班级,学员成绩按课程分别统计3.每个班级至少包含一个或多个讲师4.一个学员要有状态转化的过程 ,比如未报名前,报名后,毕业老学员5.客户 ...

  4. 将decimal类型的数据转成2.12这样价钱的显示方式

    UnitPrice = string.Format("{0:.00}", m.UnitPrice),

  5. wpf 类似TextBlock外观的Button的样式

    <Style x:Key="noborderbtnStyle" TargetType="{x:Type Button}"> <Setter P ...

  6. API CLOUD 快捷键

    常用快捷键有:Ctrl+Z:撤销Ctrl+N:创建项目或文件Ctrl+Shift+F:代码格式化(这个经常用,可以美化代码,也可以通过这个检查代码是否出错)Ctrl+/ :注释和反注释Alt+/:强制 ...

  7. Form表单的post 和get跳转区别

    post是隐示请求 ----- 安全 get显示请求不安全,会在URL上显示路径和参数

  8. linux的学习系列 4---文件权限和访问模式

    为了更加安全的存储文件,Linux为不同的文件赋予了不同的权限,每个文件都拥有下面三种权限: 所有者权限:文件所有者能够进行的操作 组权限:文件所属用户组能够进行的操作 外部权限(其他权限):其他用户 ...

  9. Math类的round方法小解

    在Math类中有三个关于“四舍五入”的静态方法(ceil,floor,round): ① Math.ceil(number) 向上取整,Math.ceil(11.2) 结果:12            ...

  10. iOS开发frame, contentSize, contentOffset, contentInset 区别联系浅析

    1. 概述 iOS开发中,必然会涉及到布局相关问题,frame,bounds,contenSize,contentOffset,contentInset这几个布局相关概念让许多初学者感到困惑.虽然初步 ...