• 竞赛排名 (Standard IO)


    题意/Description:

     

    读入/Input

           输入文件为compe.in。文件的第一行为参赛总人数N(1<=N<=100),从第二行到第N行依次为编号1到编号N的选手的成绩,每行有8个0~100之间的整数,代表该选手的8项竞赛成绩xi1,xi2,。。。,xi8。同一行相邻两个数之间用一个空格符隔开。

     

    输出/Output

           输出文件为compe.out。文件有N行,从第一行到第N行依次为排名第1的选手的编号,排名第2的选手的编号,...,排名第N的选手的编号。

     

    题解/solution

          只要把那一坨公式实现,然后多关键字排序就行了。不要用快排,不稳定。

     

    代码/Code

    var
      a:array [1..1000,1..8] of longint;
      avg,sumy:array[1..1000] of real;
      y:array [1..1000,1..8] of real;
      sum,h:array [1..1000] of longint;
      n:longint;
    procedure init;
    var
      i,j:longint;
    begin
      readln(n);
      for i:=1 to n do
        for j:=1 to 8 do
          read(a[i,j]);
    end;
    
    procedure try1;
    var
      i,j:longint;
    begin
      for i:=1 to 8 do
        begin
          for j:=1 to n do
            avg[i]:=avg[i]+a[j,i];
            avg[i]:=avg[i]/n;
        end;
    end;
    
    procedure try2;
    var
      i,j:longint;
    begin
      for i:=1 to n do
        begin
          for j:=1 to 8 do
            sum[i]:=sum[i]+a[i,j];
          h[i]:=i;
        end;
    end;
    
    procedure try3;
    var
      i,j,k:longint;
      t:real;
    begin
      for i:=1 to n do
        for j:=1 to 8 do
          begin
            t:=0;
            for k:=1 to n do
              t:=t+abs(a[k,j]-avg[j]);
            if t=0 then y[i,j]:=0
                   else y[i,j]:=(a[i,j]-avg[j])*n/t;
          end;
    end;
    
    procedure try4;
    var
      i,j:longint;
    begin
      for i:=1 to n do
        begin
          for j:=1 to 3 do
            sumy[i]:=sumy[i]+y[i,j];
          for j:=4 to 8 do
            sumy[i]:=sumy[i]+y[i,j]*0.8;
        end;
    end;
    
    procedure main;
    var
      i,j,t:longint;
      k:real;
    begin
      for i:=1 to n-1 do
        for j:=i+1 to n do
          begin
            if (sumy[i]<sumy[j]) or (sumy[i]=sumy[j]) and (sum[i]<sum[j]) or
               (sumy[i]=sumy[j]) and(sum[i]=sum[j]) and (h[i]>h[j]) then
                 begin
                   k:=sumy[i]; sumy[i]:=sumy[j]; sumy[j]:=k;
                   t:=sum[i]; sum[i]:=sum[j]; sum[j]:=t;
                   t:=h[i]; h[i]:=h[j]; h[j]:=t;
                 end;
          end;
    end;
    
    procedure print;
    var
      i:longint;
    begin
      for i:=1 to n do
        writeln(h[i]);
    end;
    
    begin
      init;
      try1;
      try2;
      try3;
      try4;
      main;
      print;
    end.



  • 相关阅读:
    LINQ表达式预备讲课
    开发中必须安装的软件
    jquery判断单选按钮radio是否选中的方法
    JQuery判断radio(单选框)是否选中和获取选中值方法总结
    jquery $.each 和for怎么跳出循环终止本次循环
    ECharts 3.0 初学感想及学习中遇到的瓶颈
    js 日期时间大小比较
    Vue资料-简介-旋之华
    vue 引用 vue-resource步骤 (遇错排解)
    vue-resource和axios的简单使用方法总结
  • 原文地址:https://www.cnblogs.com/zyx-crying/p/9319639.html
Copyright © 2020-2023  润新知