Samkit5025

Untitled

Jun 25th, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int differentValuesOfK(int N,int A,int B,int D[]){
  5.     sort(D,D+N);
  6.  
  7.     return D[B]-D[B-1];
  8. }
  9.  
  10. int main(){
  11.     int N,A,B;
  12.     cin>>N>>A>>B;
  13.  
  14.     int D[N];
  15.     for(int i=0;i<N;i++){
  16.         cin>>D[i];
  17.     }
  18.  
  19.     cout<<differentValuesOfK(N,A,B,D)<<endl;
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment