对数列求最小值
# encoding=utf-8
num,cout = input().split()
num, cout = int(num),int(cout)
lists = input().split()
lists = [ int(i) for i in lists]
def fun(lists):
print(lists)
list1 = lists
mi = min(list1)
index = list1.index(mi)
del list1[index]
i_l = lists[index-1]
i_r = lists[index+1]
ind = 0
i_s = i_l + mi
if i_l > i_r:
i_s = i_r + mi
del list1[index + 1]
else:
del list1[index - 1]
list1.append(i_s)
return list1
for i in range(cout):
lists = fun(lists)
print(min(lists))
本文标题:对数列求最小值
本文链接:https://www.haomeiwen.com/subject/dxwmaftx.html
网友评论