fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.Scanner;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int w = 0, a, b, l, d;
  13. Scanner scan = new Scanner(System.in);
  14. int r = scan.nextInt();
  15. int c = scan.nextInt();
  16. int[][] x = new int [r][r];
  17. for (int i = 0; i < r; i++)
  18. x[i] = new int[c];
  19. for (int i = 0; i < r; i++){
  20. for (int j = 0; j < c; j++){
  21. x[i][j] = scan.nextInt();
  22. }
  23. }
  24. for (int i = 0; i < r; i++){
  25. for (int j = 0; j < c; j++){
  26. a = b = l = d = 1;
  27. for (int q = 0; q < i; q++){
  28. if (x[i][j] <= x[q][j])
  29. a = 0;
  30. }
  31. for (int q = i+1; q < r; q++){
  32. if (x[i][j] <= x[q][j])
  33. b = 0;
  34. }
  35. for (int k = 0; k < j; k++){
  36. if (x[i][j] <= x[i][k])
  37. l = 0;
  38. }
  39. for (int k = j+1; k < c; k++){
  40. if (x[i][j] <= x[i][k])
  41. d = 0;
  42. }
  43. w+= a + b + l + d;
  44. }
  45. }
  46. System.out.print(w);
  47. }
  48. }
Success #stdin #stdout 0.06s 2184192KB
stdin
0 0
stdout
Standard output is empty