标签:
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[_] < 1001: 10 arr[_] -= minValue 11 cutNum += 1 12 if arr[_] <= 0: # 使不合适的值,脱衣循环 13 arr[_] = 1001 14 if cutNum != 0: # 两层循环有富裕出来,所以只输出不为0的,编码的一种动态调整 15 print cutNum 16 17 main()
学习
尝试
pop等操作
//新的思路
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 count 12 count -= 1
学习
对于顺序不重要的,完全是可以进行先排序再来的
标签:
原文地址:http://www.cnblogs.com/sangocare/p/4490685.html