题目描述 Description
小牛举办了一年一届的知识竞赛,小牛 RK 也参与其中,知识竞赛

规则是一题只有错或对两种情况,且对标志为 1,错标志为 0。每题

的分值为该题错误的人数,小牛 RK 已经知道了每个人的各个题目的

情况,他想让你求出他的总排名。(此表格规定,第一行的序号为 1,

以此类推)。

输入描述 Input Description
输入共 N+1 行

第一行输入 ID,N,M,分别表示参加的 RK 的序号,小牛个数,题

目总数。

第 2-N+1 行输入每个人每道题目的情况。
 

输出描述 Output Description
输出共 1 行

输出小牛 RK 的排名,规定成绩一样时,序号越小的排名越高。

样例输入 Sample Input
1 3 3
1 1 1
1 1 1
0 0 1

样例输出 Sample Output
1

数据范围及提示 Data Size & Hint
n,m≤1000

 

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
int count;
int num;
int p[1500];
}a[1500];
int problem[1500];
int cmp(node x,node y)
{
if(x.count!=y.count) return x.count>y.count;
if(x.num!=y.num) return x.num
}
int main()
{
int i,j,x,n,m,per,k;
scanf("%d %d %d",&x,&n,&m);
memset(a,0,sizeof(a));
memset(problem,0,sizeof(problem));
for(i=0;i
{
a[i].num=i+1;k=1;
for(j=1;j<=m;j++)
{
scanf("%d",&per);
a[i].p[k++]=per;
if(per==0)
problem[j]+=1;
}
}
for(i=0;i
{
for(j=1;j<=m;j++)
{
if(a[i].p[j]==1)
a[i].count+=problem[j];
}
}
sort(a,a+n,cmp);
for(i=0;i
{
if(a[i].num==x)
{
printf("%d\n",i+1);
break;
}
}
return 0;
}