fork(1) download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. const int MAX_SIZE = 500;
  6. int n, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  7. cin >> n;
  8. int max_product = -250000, magic_line, magic_col;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= n; ++j) {
  11. cin >> mt[i][j];
  12. int product;
  13. if (i > j) {
  14. product = mt[i][j] * (i - j);
  15. } else {
  16. product = mt[i][j] * (j - i);
  17. }
  18. if (product > max_product) {
  19. max_product = product;
  20. magic_line = i;
  21. magic_col = j;
  22. }
  23. }
  24. }
  25. cout << magic_line << " " << magic_col;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5552KB
stdin
4
1 4 5 2
10 6 2 1
8 18 4 19
3 21 0 8
stdout
4 2