閱讀95 返回首頁    go 阿裏雲 go 技術社區[雲棲]


WIKIOI-1361 知識排名

題目描述 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;
}


最後更新:2017-04-03 12:55:32

  上一篇:go N的階乘-jobdu-1076
  下一篇:go C# 打開指定路徑下文件