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=0;
    for (int i = 0; i < b; i++) {
        /* code */
        k+=sha[i];
    }
    cout<<k-1<<endl;
}
Copy
Cutting Trees sharlok not active_74
GNU G++17
42 ms
484 KB
Wrong Answer