Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 394 Bytes

23881.md

File metadata and controls

25 lines (18 loc) · 394 Bytes

23881

Python

import sys

input = sys.stdin.readline

N, K = map(int, input().split())
lst = list(map(int, input().split()))
ans = -1

for last in range(N-1, 0, -1):
    i = lst.index(max(lst[:last+1]))
    if last != i:
        lst[last], lst[i] = lst[i], lst[last]
        K -= 1
        if K == 0:
            ans = f'{lst[i]} {lst[last]}'
            break

print(ans)