Java 1-d and 2-d Array
Basic Accuracy: 28.04% Submissions: 5795 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.