Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
void MOUST(){
    ios_base::sync_with_stdio(0);
           cin.tie(0);
}
int main(){
    MOUST();

    ll n,k;cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll p=0;
    for(int i=0;i<k;i++)
        p+=a[i];
    cout<<p-1;    
}
Copy
Cutting Trees call911kid
GNU G++17
11 ms
696 KB
Wrong Answer