Skip to content

Instantly share code, notes, and snippets.

@anmolj7
Created November 25, 2018 18:51
Show Gist options
  • Save anmolj7/f3b451fe91d9db0b5fc8d45a290b7c2e to your computer and use it in GitHub Desktop.
Save anmolj7/f3b451fe91d9db0b5fc8d45a290b7c2e to your computer and use it in GitHub Desktop.
def intInput():
return int(input())
def listInput():
A = input().split()
A = [int(x) for x in A]
return A
T = intInput()
for x in range(T):
A = listInput()
N, K = A[0], A[1]
Temp = []
A = listInput()
Temp += A
A.sort(key=int, reverse=True)
B = A[:K]
output = ""
for x,y in enumerate(Temp):
if y in B:
output = output + str(y) + " "
output = output.strip()
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment