There are several books placed in the HackerStudy library. One of those books on mathematics described an interesting problem that a mathematician wishes to solve. For an array arrofnintegers, the mathematician can perform the following move on the array: 1. Choose an indexi(0≤i

Respuesta :

Using the knowledge of computational language in python it is possible to write a code that There are several books placed in the HackerStudy library.

Writting the code:

include<iostream>

using namespace std;

long getMaximumScore(int arr[],int k,int n)

{

long count=0,sum=0;

for(int i=0;i<n-1;i++)

{

 for(int j=0;j<n-i-1;j++)

 {

  if(arr[j+1]>arr[j])

  {

   arr[j+1]=arr[j+1]+arr[j];

   arr[j]=arr[j+1]-arr[j];

   arr[j+1]=arr[j+1]-arr[j];

  }

 }

}

for(int i=0;i<n;i++)

{

 if(count==k)

 return sum;

 else

 {

  sum=sum+arr[i];

  count++;

 }

}

}

int main()

{

int n,k;

cin>>n;

int arr[n];

for(k=0;k<n;k++)

cin>>arr[k]  ;

cin>>k;

cout<<getMaximumScore(arr,k,n);

return 0;

}

See more about C++ at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira