Created
November 25, 2018 18:51
-
-
Save anmolj7/f3b451fe91d9db0b5fc8d45a290b7c2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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