Accenture Solution | Code in Marathon | Codewindow.in

Solution : C++

//Codewindow.in
//Marathon solution

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int input1,input2,sum=0;
    cin>>input1;
    cin>>input2;
    int arr[input1];
    for(int i=0;i<input1;i++){
        cin>>arr[i];
    }//codewindow
    sort(arr,arr+input1,greater<int>());
    
    for(int i=0;i<input2;i++){
        sum=sum+arr[i];
    }//codewindow
    cout<<sum;

}
//end

Follow us

Also Checkout

Leave a Comment

Your email address will not be published. Required fields are marked *