#K14676. Maximum Rectangle Area

    ID: 24188 Type: Default 1000ms 256MiB

Maximum Rectangle Area

Maximum Rectangle Area

In this problem, you are given two lists of positive integers. The first list represents possible widths and the second list represents possible heights. Your task is to choose one width and one height such that the rectangular area, computed by ( \text{Area} = \text{width} \times \text{height} ), is maximized. In case there are multiple pairs yielding the same maximum area, you should output the first pair encountered during a simple nested loop iteration over the widths and heights.

For example, given widths [2, 3, 5] and heights [4, 2, 6], the maximum rectangle area is (5 \times 6 = 30), so the answer will be "30 5 6".

inputFormat

The input is read from standard input (stdin) and consists of three lines:

  1. The first line contains two integers (n) and (m) separated by a space, where (n) is the number of widths and (m) is the number of heights.
  2. The second line contains (n) positive integers representing the widths.
  3. The third line contains (m) positive integers representing the heights.

outputFormat

Output to standard output (stdout) a single line containing three integers: the maximum rectangular area, the width, and the height that produce this area. The numbers should be separated by a space.## sample

3 3
2 3 5
4 2 6
30 5 6