Source Code
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, counter = 0;
    cin >> n >> k;
    int a[n];
    //long long freq[n+1] = {0};
    for(int i = 0;i < n; i++){
        cin >> a[i];
       // freq[a[i]]++;
    }
    sort(a, a+n);
    //counter += freq[a[k-1]];
    cout << a[k-1] + (counter - 1) << endl;
}

Copy
Cutting Trees Oj3far
GNU G++17
1 ms
184 KB
Wrong Answer