12918 - Find the maximum/minimum values   

Description

In this problem, you are asked to implement a program which can find the maximum element M and minimum element of a two-dimensional array. You need to print the location difference and value difference of M and m. For example, if M is at iM-th row and jM-th column and of value rM, and m is at im-th row and jm-th column and of value rm, then the location difference and value difference of the two elements are (|iM - im| + |jM - jm|) and (|rM - rm|), respectively.

Note that in a given array, no two elements will have the same value.

 

HINT: You can use C library function:  int abs(int x) ,which returns the absolute value of int x.

Before using abs(), you may need to add the following code at first : #include <stdlib.h>

Input

The first line of the input contains two integer numbers R (2<=R<=10) and C (2<=C<=10).

Each of the next R lines contains C integers, specifying the elements of the two-dimensional array. All of the integers in the same line are separated by a space.

Output

The output contains two integers:  the location difference and the value difference of the maximum and minimum elements, separated by a space.

Note that you do not need to print ‘\n’ at the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss