#38037: Python 簡易解


110649@st.tysh.tyc.edu.tw (20820黃少楷)

學校 : 不指定學校
編號 : 237993
來源 : [61.228.51.106]
最後登入時間 :
2025-08-18 22:58:41

p,k=map(int,input().split())
lst=list(map(int,input().split()))
lst=sorted(lst)
n=0
num=0
countx=0
county=0
while k>n:
    if lst[num]>p:
        n+=1
        num+=1
        countx+=1
    elif lst[num]<p:
        n+=1
        num+=1
        county+=1
if countx>county:
    print(countx,lst[k-1])
elif countx<county:
    print(county,lst[0])