Minimum Profit - N days - WIPRO

Minimum Profit - N days - WIPRO 

Problem:

A shop has M sales each day for N days. Each day different types of items were sold and had different profits associated with them, but the number of items sold on each day was the same. The program must accept the values of M, N and the profits earned from the M sales for N days as the input. The program must print the minimum profit earned on each day as the output. 

Boundary Condition(s): 

2 <= M, N <= 50 

1 <= Profit for each sale <= 1000 

Input Format: 

The first line contains M and N separated by a space. The next M lines, each contains N integers separated by a space. 

Output Format: 

The first line contains the minimum profit earned on each day separated by a space. 

Example Input/Output 1: 

Input: 

5 3 

5 7 10 

2 14 6 

1 8 11 

3 9 15 

12 4 7 

Output: 

1 4 6 

Explanation: 

On the first day, the profits earned from the 5 sales are 5, 2, 1, 3 and 12. Here 1 is the minimum profit, so 1 is printed. On the second day, the profits earned from the 5 sales are 7, 14, 8, 9 and 4. Here 4 is the minimum profit, so 4 is printed. On the third day, the profits earned from the 5 sales are 10, 6, 11, 15 and 7. Here 6 is the minimum profit, so 6 is printed. Hence the output is 1 4 6 

Example Input/Output 2: 

Input: 

2 5 

25 20 18 24 19 

21 11 23 17 15 

Output: 

21 11 18 17 15

Program:

m,n = map(int,input().split())

l = []

for i in range(m):

    l.append(list(map(int,input().split())))

t = []

for i in range(n): 

    a = l[0][i]

    for j in range(1,m): 

        a = min(a,l[j][i])

    print(a,end=" ")


Comments

Popular posts from this blog

Pronic Integers in N - InfyTQ question

Count Strong Points - Accenture

Letters at position of multiples of a number