fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. double n, m;
  10. double x, min = 100, max = -100, sum = 0, a = 0, b = 0;
  11. Scanner in = new Scanner(System.in);
  12. n = in.nextDouble();
  13. m = in.nextDouble();
  14. for (int i = 0; i < m; i++){
  15. for (int j = 0; j < n; j ++){
  16. x = in.nextDouble();
  17. if (max == x) a++;
  18. if (max < x) {
  19. if (max != min) sum += a*max;
  20. a = 1;
  21. max = x;
  22. }
  23. if ( min == x) b++;
  24. if (min > x) {
  25. if (max != min) sum += b*min;
  26. b = 1;
  27. min = x;
  28. }
  29. if (x!= min && x != max) sum += x;
  30. }
  31. if(i == m-1) System.out.printf("%.2f", sum / (n - a - b));
  32. else System.out.printf("%.2f ", sum / (n - a - b));
  33. sum = a = b = 0;
  34. min = 100;
  35. max = -100;
  36. }
  37. }
  38. }
Success #stdin #stdout 0.08s 2184192KB
stdin
4 4
7 7 2 3
9 8 3 3
5 4 9 7
4 3 2 6
stdout
3.00 8.00 6.00 3.50