Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve this problem using C language Hacker Industries has a number of employees. The company assigns each employee a numeric evaluation score and stores
Please solve this problem using C language
Hacker Industries has a number of employees. The company assigns each employee a numeric evaluation score and stores these scores in a list. A manager is assembling a team for a new project and selects a number of employees from the list to create a team. He selects the team members in the following way: 1. During each selection, the manager chooses the employee with the highest score among either the first m available employees or the last m available employees in the list. The manager then removes the selected employee from the list and adds them to the team. That employee's score is stored to the team list. 2. If there are multiple employees with the same highest score among the first or last m available employees, the manager selects the employee whose score is at the lowest index in the list of scores. 3. If there are fewer than m available employees, then the manager picks the employee with the highest score from available employees. For example, consider a company with 5 employees, with score = [10, 20, 10, 15, 5] respectively. A team of two employees needs to be formed, and the value of m is given to be 1. During the first selection, choose between the leftmost m elements: [10] and the rightmost m elements: [5]. The employee with score 10 is added to the team (10>5), and removed from the list. This makes score = [20, 10, 15, 5]. During the second selection, employee with score 20 is added to the team (20 > 5), and removed from the list. This makes score = [10, 15, 5]. Hence, the total sum of the selected employees' scores is 10 + 20 = 30. Function Description Complete the function teamFormation in the editor below. The function must return the sum of the scores of all members selected for the team. teamFormation has the following parameter(s): score[score[0],....score[n-1]]: an array of scores for each employee. team: the number of team members required. m: the size of the array segments to select from. Constraints 1 n 105 1 score[i] 10 1 team s n 1mn Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the size of the array score. The next n lines each contain an element score[i] where 0 i 1 + #include ... 19 20 1 22 23 24 25 26 7 28 29 30 31 32 33 34 19 | 21 27 / + * Complete the 'team Formation' function below. } * The function is expected to return a LONG_INTEGER. function accepts following parameters: The 1. INTEGER_ARRAY score + + 2. INTEGER team + 3. INTEGER m +/ long team Formation(int score_count, int* score, int team, int m) { 34 int main() ---
Step by Step Solution
★★★★★
3.46 Rating (162 Votes )
There are 3 Steps involved in it
Step: 1
Code pasted below can be executed online at following URL httpswwwonlinegdbcomBJHQqZmU Stdin input u...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started