Cut the sticks, cutthesticks
1 def main (): 2 n = int (raw_input () 3 arr = map (int, raw_input (). strip (). split () 4 5 for I in range (n): 6 cutNum = 0 7 minValue = min (arr) 8 for _ in range (n ): 9 if 0 <arr [_] <100:10 arr [_]-= minValue11 cutNum + = 112 if arr [_] <= 0: # Make an inappropriate value, undun loop 13 arr [_] = 100114 if cutNum! = 0: # Two-layer loops are rich, so only the output is not 0. A dynamic adjustment of the encoding is 15 print cutNum16 17 main ()
Learning
Try
Pop and other operations
// New ideas
1 n = int(raw_input().strip()) 2 sticks = [int(i) for i in raw_input().strip().split()] 3 sticks.sort() 4 newItem = sticks[0] 5 count = len(sticks) 6 print count 7 count -= 1 8 for i in range(1, len(sticks)): 9 if sticks[i] != newItem:10 newItem = sticks[i]11 print count12 count -= 1
Learning
The sequence is not important. It can be sorted first.