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
zhenek [66]
3 years ago
14

/* Function findBestVacation * duration: number of vacation days * prefs: prefs[k] indicates the rate specified for game k * pla

n: array with 366 positions with the sequence of games * to be played over the year. In other words, * plan[k] indicates the game planned for day k (1

Engineering
1 answer:
alexira [117]3 years ago
3 0

Answer:

This is the C++ code for the above problem:

#include<bits/stdc++.h>

using namespace std;

int computeFunLevel(int start, int duration, int prefs[], int ngames, int plan[]) {

if(start + duration > 365) { //this is to check wether duration is more than total no. of vaccation days

return -1;

}

int funLevel = 0;

for(int i=start; i<start+duration; i++) { //this loop runs from starting point till

//start + duration to sum all the funlevel in plan.

funLevel = funLevel + prefs[plan[i]];

}

return funLevel;

}

int findBestVacation(int duration, int prefs[], int ngames, int plan[]) {

int max = 0, index = 0, sum = 0 ;

for(int i=1; i<11; i++){ //this loop is to run through whole plan arry

sum = 0; //sum is initialized with zero for every call in plan ,

//in this case loop should run to 366,but for example it is 11

//as my size of plan array is 11

for(int j=0; j<duration; j++) { // this loop is for that index to index+duration to calc

//fun from that index

sum = sum + prefs[plan[i]];

}

if(sum>max) { //this is to check max funlevel and update the index from which max fun can be achieved

max = sum;

index = i;

}

}

return index;

}

int main() {

int ngames = 5;

int prefs[] = { 1,2,0,5,2 };

int plan[] = { 0,2,0,3,3,4,0,1,2,3,3 };

int start = 1;

int duration = 4;

cout << computeFunLevel(start, duration, prefs, ngames, plan) << endl;

cout << computeFunLevel(start, 555, prefs, ngames, plan) << endl;

cout << findBestVacation(4, prefs, ngames, plan) << endl;

}

The screen of the program is given below.

You might be interested in
Name two types of battery chargers that are used in mechanics
tekilochka [14]
Primary batteries
Secondary batteries
7 0
3 years ago
What does polarity give you information about?
Brrunno [24]

Well, I do know that polarity affects the voltage.

6 0
3 years ago
You leave your house at 5:02 PM and run 20 yards down the street. You don't realize that you forgot your Wallet back at home and
Sidana [21]

Answer:

The average velocity is 0.203 m/s

Explanation:

Given;

initial displacement, x₁ = 20 yards = 18.288 m

final displacement, x₂ = ¹/₃ x 18.288 = 6.096 m

change in time between 5:02 PM and 5:03 PM, Δt = 3 mins - 2 mins = 1 min = 60 s

The average velocity is given by;

V = change in displacement / change in time

V = (x₂ - x₁) / Δt

V = (18.288 - 6.096) / 60

V = 0.203 m/s

Therefore, the average velocity is 0.203 m/s

7 0
3 years ago
Where can you find free air pods that look real
Tema [17]
You can find air pods that look real on letgo. or you can go to wish.com but if you want a good pair jus get the real ones
7 0
3 years ago
To provide some perspective on the dimensions of atomic defects, consider a metal specimen that has a dislocation density of 105
GenaCL600 [577]

Answer:

62.14\ \text{miles}

6213727.37\ \text{miles}

Explanation:

The distance of the chain would be the product of the dislocation density and the volume of the metal.

Dislocation density = 10^5\ \text{mm}^{-2}

Volume of the metal = 1000\ \text{mm}^3

10^5\times 1000=10^8\ \text{mm}\\ =10^5\ \text{m}

1\ \text{mile}=1609.34\ \text{m}

\dfrac{10^5}{1609.34}=62.14\ \text{miles}

The chain would extend 62.14\ \text{miles}

Dislocation density = 10^{10}\ \text{mm}^{-2}

Volume of the metal = 1000\ \text{mm}^3

10^{10}\times 1000=10^{13}\ \text{mm}\\ =10^{10}\ \text{m}

\dfrac{10^{10}}{1609.34}=6213727.37\ \text{miles}

The chain would extend 6213727.37\ \text{miles}

3 0
3 years ago
Other questions:
  • Block A has a weight of 8 lb. and block B has a weight of 6 lb. They rest on a surface for which the coefficient of kinetic fric
    8·1 answer
  • A 3-phase induction motor with 4 poles is being driven at 45 Hz and is running in its normal operating range. When connected to
    12·1 answer
  • If the resistance reading on a DMM'S meter face is to 22.5 ohms in the range selector switch is set to R X 100 range, what is th
    5·1 answer
  • If the Zener diode is connected<br>wrong polarity the voltage<br>across the load is?​
    11·1 answer
  • Which definition best fits the idea of electrical resistance in a wire? A. the decrease in current flow due to electrons collidi
    12·1 answer
  • George is replacing a burned out resistor in a circuit board. The board has a 10, a 20, and a 40 on resistor, all in parallel. W
    5·1 answer
  • if you help then I will thank u by sooo much I will give tons of points but the answer has to be right.
    14·2 answers
  • 3. What is special about beryllium-copper alloy tools?
    6·2 answers
  • When you approach an uncontrolled intersection, you should treat it as though which sign is present?
    15·1 answer
  • The regulator is closed when the adjusting screw is turned in (clockwise).
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!