Title Description
Xiao Yi There is an old game consoles, has a top classic game Tetris. Because it is relatively old, so the general rules of Tetris and different.
A total of n columns on the screen, every time there is a 1 x 1 block of randomly dropped, in the same column, the box will fall stacked over the previous block, when a whole block row are occupied, this line will be eliminated, and get 1 point.
One day, Xiao Yi has opened a game, when the first m squares to play down he felt too bored turned off, Xiao Yi hope you get him to tell him the score of this game round.
Input Description :
The first line of the two numbers n, m
the number of the second line m, c1, c2, ..., cm, ci denotes an i-th block of the falling columns
where 1 <= n, m <= 1000 , 1 <= ci <= n
Output Description :
Score this board game Xiao Yi obtained
1 line1 = [int(x) for x in input().strip().split()] 2 n,m = line1[0],line1[1] 3 blocks = [int(x) for x in input().strip().split()] 4 5 dic = {} 6 for i in range(1,n+1): 7 dic[i] = 0 8 for i in range(m): 9 dic[blocks[i]] += 1 10 rows = min(dic.values()) 11 print(rows)
Algorithms ideas: greed.
The number of records for each column appeared, the minimum height of all columns, number of rows is eliminated.