Source Code
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,cnt=0;cin>>a>>b;
    int sha[a];
    for (int i = 0; i < a; i++) {
        /* code */
        cin>>sha[i];
    }
    sort(sha,sha+a);
    int k=sha[b-1];
    for (int i = b-2;i >=0 ; i--) {
        /* code */
        if(k==sha[i]){
            cnt++;
        }else break;
    }
    cout<<k+cnt<<endl;
}
Copy
Cutting Trees sharlok not active_74
GNU G++17
61 ms
696 KB
Wrong Answer