简单排序题。

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

#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. libprotobuff8.so not found

    http://stackoverflow.com/questions/25518701/protobuf-cannot-find-shared-libraries

  2. TOMCAT-publishing to tomcat v7.0 server at

    因为tomcat的work文件没有清空,导致MyEclipse部署在server.xml文件中的项目路径是错误的. 解决办法:清空work文件夹 下面这个勾勾是MyEclipse自动发布项目路径的选项

  3. php redis 消息队列

    redis是什么东西就不多说了,网上文章一搜一大堆. 首先来说一下我要实现的功能: 类似一个消息中转站吧,如果有人要发送消息,先将消息发到我这里来,然后我这边进行转发,为的就是有一个统一的管理和修改时 ...

  4. Hibernate 系列教程5-双向多对一

    主要讲解inverse和cascade的用法 cascade定义的是关系两端对象到对象的级联关系: 而inverse定义的是关系和对象的级联关系(管理外键的值). inverse 属性默认是false ...

  5. libmysql.dll 找不到

    在用C#开发的时候,需要连接MySQL  ,系统提示  libmysql.dll 找不到模块. 我们可以找到 MySQL安装文件夹下的 C:\Program Files\MySQL\MySQL Ser ...

  6. jz2440 环境搭建遇到的问题

    已解决:

  7. Android开发10.2:UI组件AutoCompleteTextView(自动完成文本框)

    概述 AutoCompleteTextVeiw(自动完成文本框)从 EditText派生而出  PS :EditText用法介绍           当用户输入一定字符后,自动完成自动完成文本框会显示 ...

  8. haxe 配置

    安装所有类库: 命令提示符 haxelib install 类库名 如:haxelib install openfl 配置安卓: 命令提示符 haxelib run openfl setup andr ...

  9. ubuntu11.10server 安装php-redis插件

    1.下载php-redis插件 1 sudo wget https://github.com/nicolasff/phpredis/archive/master.zip 2.安装 1 2 3 4 5 ...

  10. C++:string类的使用

    类 <string> std::string String类的定义 , 其也是个模板类 typedef basic_string<char> string; String cl ...