Very Easy || Solution C++


#1

int Solution::solve(vector &A, int B) {
int n=A.size(),count=0;
sort(A.begin(),A.end());
for(int i=1;i<=B;i++){
count+=A[n-1];
A[n-1]=A[n-1]-1;
sort(A.begin(),A.end());
}
return count;
}