简单排序题。

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

#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. linkButton

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  2. 转 Oracle 12C 之 CDB/PDB用户的创建与对象管理

    在Oracle 12C中,账号分为两种,一种是公用账号,一种是本地账号(亦可理解为私有账号).共有账号是指在CDB下创建,并在全部PDB中生效的账号,另一种是在PDB中创建的账号. 针对这两种账号的测 ...

  3. 【中国剩余定理】 poj 1006

    生理周期  简单模拟 对于超出23 * 28 * 33(21252)时进行求余运算即可. #include<stdio.h> int main() { //freopen("in ...

  4. WPF Template模版之DataTemplate与ControlTemplate的关系和应用【二】

    1. DataTemplate和ControlTemplate的关系 学习过DataTemplate和ControlTemplate,你应该已经体会到,控件只是数据的行为和载体,是个抽象的概念,至于它 ...

  5. php 编程效率(1)

    用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则 不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中 ...

  6. 设置控件全局显示样式 appearance

    iOS5及其以后提供了一个比较强大的工具UIAppearance,我们通过UIAppearance设置一些UI的全局效果,这样就可以很方便的实现UI的自定义效果又能最简单的实现统一界面风格,它提供如下 ...

  7. HDU 1232 畅通工程(最小生成树+并查集)

    畅通工程 Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissi ...

  8. Light OJ - 1058 Parallelogram Counting(判定平行四边形)

    Description There are n distinct points in the plane, given by their integer coordinates. Find the n ...

  9. C++中运行外部程序

    关于三个SDK函数: WinExec, ShellExecute,CreateProcess 的其他注意事项: [1]定义头文件 必须定义以下两个头文件: #include <shlobj.h& ...

  10. Chapter 1 First Sight——15

    The red-haired woman looked up. "Can I help you?" 红头发的女人抬头看了一眼说,有什么我能帮助你的吗? "I'm Isab ...