fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lli long long int
  4. vector<lli> a;
  5. int main()
  6. {
  7. lli n,k,val;
  8. cin>>n>>k;
  9. for(lli i=0;i<n;i++)
  10. {
  11. cin>>val;
  12. a.push_back(val);
  13. }
  14. sort(a.begin(),a.end(),greater<lli>());
  15. cout<<a[k-1];
  16. return 0;
  17. }
Success #stdin #stdout 0s 4196KB
stdin
3 2 
3 1 4
stdout
3