L2-041 插松枝——Python3

题目

L2-041 插松枝——Python3_第1张图片

输入样例:

8 3 4
20 25 15 18 20 18 8 5

输出样例:

20 15
20 18 18 8
25 5

 代码:

h=[]
k=[]
h1=100000

n,m,k1 = map(int,input().split())
a=list(map(int,input().split()))

while True:
    if not k and not a:
        print(' '.join(map(str,h)))
        break
    else:
        if len(k)==m and a and a[0]>h1 or k and k[-1]>h1 and a==[] or len(h)==k1:
            print(' '.join(map(str, h)))
            h=[]
            h1=100000
        else:
            if not k or k[-1]>h1:
                for _ in range(n):
                    if len(k) &

你可能感兴趣的:(Python,python,算法,数据结构)