1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
IrinaVladis [17]
4 years ago
10

Even-Odd Operations Given an array of non-negative integers, perform a series of operations until the array becomes empty. Each

of the operations gives a score, and the goal is to maximize the overall score, the sum of the scores from all operations. Determine the maximum possible score after performing the operations on the array. All operations are 1-indexed, and are defined as follows: 1. For every odd-indexed operation, the score is the sum of all integers present in the array. 2. For every even-indexed operation, the score is the negative of the sum of all integers present in the array. 3. After every operation (odd or even), remove either the leftmost or the rightmost integer from the array. For example: Let integerArray = [3, 6, 8] Initial score = 0 The operations are as follows: 1. Operation 1 is odd, so add the sum of the array to the score. score = 3 + 6 + 8 = 17 Choose to delete the rightmost integer (i.e. 8), and now integerArray = [3, 6] 2. Operation 2 is even, so subtract the sum of the array from the score. sum = 3 + 6 = 9 and score = 17 - sum = 17 - 9 = 8 Choose to delete the leftmost integer (i.e. 3), and now integerArray = [6] 3. Operation 3 is odd, so add the sum of the array to the score sum-hand score – 8I sum - 816 - 11 2. Uperation 2 is even, so subtract the sum of the array from the score. sum = 3 + 6 = 9 and score = 17 - sum = 17 - 9 = 8 Choose to delete the leftmost integer (i.e. 3), and now integerArray = [6] 3. Operation 3 is odd, so add the sum of the array to the score. sum = 6 and score = 8 + sum = 8 + 6 = 14 Only one element is left. It is both the leftmost and rightmost element, so delete it (i.e. 6), and now integerArray = [ ] The array is now empty, so no further operations are possible. The maximum possible score is 14. Function Description Complete the function getMaximumScore in the editor below. The function must return the maximum possible score after performing all the operations. getMaximumScore has the following parameter: integerArray: an array of integers Constraints • 1 s size of integerArray < 103 • 0 s integerArray[i] = 109

Computers and Technology
2 answers:
maxonik [38]4 years ago
7 0

Answer:

# include<iostream>

# include<stdio.h>

# include<stdlib.h>

using namespace::std;

int main()

{

   int *a=NULL;

   int n; int score=0;

   cout<<"Enter the value of N";

   cin>>n;

   a=new int[n];

   cout<<"Enter the elements of a";

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

   {

       cin>>a[i];

   }

   int num=n;int k=n;int j=num;

   while(j>=num)

   {

   if(n%2==0)

   {

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

     {

         score+=a[i];cout<<score;      }

     if(a[0]>a[n])

       {

             a[n]=0;

             n--;

         }

     else if(a[0]<a[n])

     {

           a[0]=0;

           n--;

     }

     else if(n==1)

     {

         exit(0);

     }

     

   }

   else

   {

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

       {

           score-=a[i];

       }

       if(a[0]>a[n])

       {

             a[n]=0;

             n--;

       }

     else if(a[0]<a[n])

     {

           a[0]==0;

           n--;

     }

     else

     {

         exit(0);

     }

   }

   j--;

   }

   cout<<"score"<<score;

   return 0;

}

Explanation:

The array above is created dynamically, and rest is as mentioned in question.

ivann1987 [24]4 years ago
6 0

Answer:

Explanation:

def getMaximumScore(array, n):

   """

       array: list of positive numbers/integers

       n : size of array

       return: score (maximum)

   """

   score=0  # initially zero

   operation = "Odd"

   while len(array)!=0:

       s = sum(array)

       if operation=="Odd":

           score+=s

           operation="Even"

           del(array[-1])

       elif operation=="Even":

           score-=s

           operation="Odd"

           del(array[0])

   return score

print("Maximum score: "+str(getMaximumScore([3,6,8],3)))

You might be interested in
What is the different between information and data
Vika [28.1K]
Data is an individual unit that contains raw materials which do not carry any specific meaning. Information is a group of data that collectively carries a logical meaning.
7 0
3 years ago
reagan's firm has not had to make large investments in computer or networking hardware or in personnel to maintain the hardware
GrogVix [38]

Since Reagan's firm has not had to make large investments in computer or networking hardware, the  key benefit of public cloud computing is option B:  reduced costs.

<h3>What equipment is employed for networking?</h3>

There are different kinds of equipment for networks. Hardware for networking is required for computers to communicate with one another. Bridges, hubs, as well as switches, and routers are all networking devices with slightly varied functions.

Therefore, In a public cloud, resources are made available by a third party provider through the internet and shared by businesses and individuals who want to use or buy them and low cost is a good advantage.

Learn more about cloud computing  from

brainly.com/question/19057393
#SPJ1

3 0
1 year ago
In a particular field, there are trees in a l single row from left to right. Each tree has a value V You cut trees from left to
Sedbober [7]

Answer:

i dont know help me

Explanation:

4 0
3 years ago
Read 2 more answers
What is the difference between a ROM chip and a RAM chip?
Leokris [45]

Answer:

A: A ROM chip is non-volatile and will keep its data in the case of a power failure. A RAM chip is volatile and will wipe its data in the case of a power failure.

Explanation:

ROM chips were widely used at the time of the old consoles, because with it you had an extremely fast and non-volatile memory, but this technology is very expensive and started to use CDs in the Consoles, while the RAM memory is a memory of execution random (RAM = RANDOM ACESS MEMORY).

4 0
3 years ago
A(n) _____ is the component of an expert system that performs tasks similar to what a human expert does by explaining to end use
Rainbow [258]

Answer:

Explanation facility

Explanation:

Expert systems leverage the ability of artifical intelligence as they are computer programs which have the ability of learning over time from a particular expert on a certain knowledge base or field in other to be reproduce or simulate the responses or capability of the expert based on the same subject. The expert system is composed of components such as the knowledge base, inference engine, knowledge and learning module, user interface and the Explanation facility . What the explanation facility typically does is explains to the user why and how a particular recommendation is made or how it reached a certain conclusion

6 0
3 years ago
Other questions:
  • A restaurant bill comes to $28.35. Find the total cost if the tax is 6.25% and a 20% tip is left on the amount before tax.​
    6·1 answer
  • A computer that stores and distributes newsgroup messages is called a newsreader.
    13·1 answer
  • Why are video games interesting?
    5·1 answer
  • Ted is asked to create a page of family photos for his family reunion Web site. He will have about 20 pictures to post, with a c
    5·1 answer
  • What are the implications for a company that relies solely on technology to store all of their data ?
    5·1 answer
  • Write a program that prompts the user to enter the minutes (e.g., 1 billion), and displays the number of years and days for the
    7·1 answer
  • Select the tips you should follow when writing a business report.
    12·1 answer
  • I NEED THIS ASAP
    12·2 answers
  • Which of these sentences correctly shows how youngsters use the Internet?
    13·1 answer
  • Use a slicer to filter the data in this table to show only rows where the Category value is Coffee or Meals
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!