简单排序题。

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

#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. javascript克隆一个对象

    /* * 克隆一个对象 */ com.ty.repairtech.JsonOperation.clone = function(obj) { // Handle the 3 simple types, ...

  2. 被非技术瓶颈阻挡了,没钱买Mac,挣扎ing

    最近一直没来写博客,因为一直在找刷盘子.服务生.看店的工. 已经找到,主要因为前阵子天不热,所以酒馆的顾客不多.现在好了. 只好买个Mac mini,看了很多帖子,也只好暂时折中这样了.Mac买不起. ...

  3. 注意题目条件!!! 团问题 HDU 5952

    题目大意:团的定义就是,团内的所有点,两两之间各有一条边,团的大小就是点的个数.现给你一个n个点,m条边的图.问,该图中有多少点的个数为s的团. (题目保证每个点的度数不超过20,n<=100, ...

  4. iptables进行端口重定向

    使用iptables进行端口重定向,方法如下: 在机器A上操作: #iptables -t nat -A PREROUTING -d 192.168.203.173 -p tcp -m tcp --d ...

  5. fp oo

    http://blog.enfranchisedmind.com/2009/05/scala-not-functional/

  6. 笨方法学python--字符串和文本

    1print 变量 abc = False joke_string = "Isn't that joke so funny?! %r" print joke_string %abc ...

  7. iabtis初探

    1.简介 与Hibernate相比,ibatis属于一种半自动的ORM框架,主要解决了java对象与SQL入参及结果集的映射关系.简单易学.容易上手:但是安全性较差,对于金融等对安全要求较高的系统来说 ...

  8. jQuery实现父窗口的问题

    因为先前遇到的问题,所以我考虑采用 IFRAME 来隔离不同的脚本,从而实现我需要的效果. 在框架中,我用 JavaScript 获取 JSON 数据,组织成 HTML 代码,最后将其填充至上层文档的 ...

  9. JQuery Each循环遍历每个元素

    输出每个 li 元素的文本: $("button").click(function(){ $("li").each(function(){ alert($(th ...

  10. Android OpenGL ES(九)绘制线段Line Segment .

    创建一个DrawLine Activity,定义四个顶点: float vertexArray[] = { -0.8f, -0.4f * 1.732f, 0.0f, -0.4f, 0.4f * 1.7 ...