PAT B 1092 is best to eat moon cake

The code was released, we learn together, help each other
Title:
moon cake is one of China's long traditional cakes prestigious, since the Tang Dynasty, has developed hundreds of varieties.
For competitions a kind of "best eating" moon cake, eat goods sector that is bound to lead to a reign of terror in ...... here we use the number of words, given the country a variety of moon cake sales, requiring you to find out the sales champion, identified as the best to eat moon cake.

Input format:
input is first given two positive integers N (≤1000) and M (≤100), respectively, the number of kinds of moon cake (moon cake so the default type number from 1 to N) and the number of cities participating statistics.

Next M rows, each row is given a non-negative integer N (no more than 1 million), which is an integer of i-th moon cake sales of the i-th (block). Between numbers separated by a space.

Output format:
maximum output volume in the first row, the type of the highest-numbered second row output moon cake volume. If the winner is not unique, press the numbers in ascending order output tied for the championship. Between numbers separated by a space, the line from beginning to end may not have the extra space.

Sample input:

5 3
1001 992 0 233 6
8 0 2018 0 2008
36 18 0 1024 4

Sample output:

2018
3 5

Code below (Python):

def max_index(lst_int):
    index = []
    max_n = max(lst_int)
    for i in range(len(lst_int)):
        if lst_int[i] == max_n:
            index.append(str(i + 1))
    return index

x, y = [int(x) for x in input().split()]
info = [0 for i in range(x)]
for i in range(y):
    lst = list(map(int, input().split()))
    info = [n + m for m, n in zip(info, lst)]
print(max(info))
print(' '.join(max_index(info)))
Published 65 original articles · won praise 25 · views 1023

Guess you like

Origin blog.csdn.net/chongchujianghu3/article/details/104987434