比赛 小练习赛:A组 评测结果 AAAAAAAAAA
题目名称 自动统计机 最终得分 100
用户昵称 思邈然 运行时间 0.003 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2014-10-21 18:37:54
显示代码纯文本
  1. program cogs126;
  2. var
  3. a:array[1..500]of integer;
  4. n,i:integer;
  5. add:real;
  6. procedure qsort(l,r:integer);
  7. var
  8. x,y,z,t:integer;
  9. begin
  10. x:=l;y:=r; z:=a[(r+l)shr 1];
  11. repeat
  12. while a[x]<z do inc(x);
  13. while a[y]>z do dec(y);
  14. if x<=y then begin
  15. t:=a[x];a[x]:=a[y];a[y]:=t;
  16. inc(x);dec(y); end;
  17. until x>y;
  18. if x<r then qsort(x,r);
  19. if y>l then qsort(l,y);
  20. end;
  21. begin
  22. assign(input,'stats.in');reset(input);
  23. assign(output,'stats.out');rewrite(output);
  24. readln(n); add:=0;
  25. for i:=1 to n do begin
  26. readln(a[i]);
  27. add:=add+a[i]; end;
  28. qsort(1,n);
  29. writeln(add/n:0:6);
  30. if odd(n) then add:=a[(n+1)shr 1]
  31. else add:=(a[n shr 1]+a[n shr 1 +1])/2;
  32. writeln(add:0:6);
  33. close(input);close(output);
  34. end.
  35.