数据竟然不允许前两个数相同,要加上and l[i] != l[a]。。。

n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n - 2):
    if i > 0 and l[i] == l[i-1]:
        continue
    x = k - l[i]
    a = i + 1
    b = n - 1
    while a < b:
        tmp = l[a] + l[b]
        if tmp == x and l[i] != l[a]:
            print(l[i], l[a], l[b])
            a += 1
            b -= 1
            while l[a] == l[a-1] and a < b:
                a += 1
            while l[b] == l[b+1] and a < b:
                b -= 1
        elif tmp < x:
            a += 1
        else:
            b -= 1