Java 1-d and 2-d Array
Submissions: 5069   Accuracy:

25.14%

  Difficulty: Basic   Marks: 1

Given a integer n. We have n*n values of a 2-d array, and  n values of 1-d array. Task is to find the sum of the diagonal values of the 2-d array and the max element of the 1-d array and print them with space in between.

Input: First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a integer n. Second line consists of n*n spaced integers. Third and last line consists of n spaced integers.

Output: Print the sum of the diagonal elements and the maximum number of the 1-d array with spaces in between.

Constraints:

1<=T<=100
1<= n <=100
1<=element<=103


Example:

Input:
1
3
1 2 3 4 5 6 7 8 9
3 6 9

Output:
15 9

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: S_A
Author: saksham0751


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.