Advertisement
TimxAG

Untitled

May 6th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3.  
  4. int main()
  5. {
  6.  
  7. int n,k,i;
  8. std::cin >> n >> k;
  9. int a[n];
  10. for (i=0; i<n; i++)
  11. std::cin >> a[i];
  12. std::sort(a,a+n);
  13. if (k==0 || a[k-1]==a[k])
  14. std::cout << -1;
  15. else
  16. std::cout << a[k]-1;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement