TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Consider the table of 32-bit signed integers with n rows and m columns. The columns are numbered from
1 to m beginning from the left side of the table. Let Ai
(1 ≤ i ≤ m) is the product of all numbers in the i-th column.
Find the maximum of these products and print the column number where this maximum product is achieved. If
there are many such columns, print the largest number of the column.

Input Format

Consists of multiple tests. Each test begins with a line with two integers m and n (1 ≤ m ≤ 20, 1 ≤ n
≤ 1000). Each of the next n lines contains m 32-bit signed integers.

Output Format

For each test case print on a separate line the column number with the maximum product. If
there are several of them – print the largest number of such column.

Sample Input 1

3 3
20 10 30
15 20 20
30 30 20
3 2
2 -2 2
2 -2 2

Sample Output 1

3
3

Hints

Problem Source

Migrated from old NTUJ.

SEERC 2010

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200