fork(1) download
  1. #include <iostream>
  2. #define N 750
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, m, MIN[N], MAX[N];
  7. cin >> n >> m;
  8. for (int i = 0; i < n; i++) {
  9. for (int j = 0; j < m; j++) {
  10. int input;
  11. cin >> input;
  12. if (i == 0) MAX[j] = input;
  13. else if (MAX[j] < input) MAX[j] = input;
  14. if (j == 0) MIN[i] = input;
  15. else if (MIN[i] > input) MIN[i] = input;
  16. }
  17. }
  18. int count = 0;
  19. for (int i = 0; i < n; i++)
  20. for (int j = 0; j < m; j++)
  21. if (MIN[i] == MAX[j]) count++;
  22. cout << count;
  23. return 0;
  24. }
Success #stdin #stdout 0s 15232KB
stdin
2 2
1 1
1 1
stdout
4