Problem C
Expression Again
Input: standard input
Output: standard output
Time Limit: 6 seconds
You are given an algebraic expression of the form (x1+x2+x3+.....+xn)*(y1+y2+.........+ym) and (n+m) integers. You have to find the maximum and minimum value of the expression using the given integers. For example if you are given (x1+x2)*(y1+y2) and you are given 1, 2, 3 and 4. Then maximum value is (1+4)*(2+3) = 25 whereas minimum value is (4+3)*(2+1) = 21.
Each input set starts with two positive integers N, M (less than 51). Next line follows (N+M) integers which are in the range of -50 to 50. Input is terminated by end of file. There will be atmost 110 testcases.
Output is one line for each case, maximum value followed by minimum value.
2 2 1 2 3 4 3 1 1 2 3 4 2 2 2 2 2 2 |
25 21 24 9 16 16 |
Problem setter: Md
Kamruzzaman, Member of Elite Problemsetters' Panel