The Matrix

3

3 votes
Medium
Problem

Pratik is a huge fan of The Matrix. He says he can perform matrix operations in his mind. So to test this his friend rohit gave him two matrices A(pxq) and B(qxr), he asked pratik to multiply these matrices and calculate sum of each row and each column and give the highest of these numbers as answer.


Score = max(0, x), where x=(800num of characters in code)8

 

INPUT:
first line of input contains two space separated integers denoting p and q.
each of the next p lines contains q space separated integers
next line of input contains two space separated integers denoting q and r.
each of the next q lines contains r space separated integers

 

OUTPUT:
print the maximum of sum of each row and each column.

 

CONSTRAINTS:
0<=Aij,Bij<=99
3<=p,q,r<=100

Sample Input
3 3
8 9 1
5 2 3
4 6 5
3 3
1 2 3
4 5 6
7 8 9
Sample Output
234
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

for the sample input:

matrix after multiplication is 

51	69	87
34	44	54
63	78	93

row sums: 207 132 234
column sums: 148 191 234
highest of these is 234

Editor Image

?