The manager of a company is required to complete n projects, where the number of…
- User
The manager of a company is required to complete n projects, where the number of employees required and the bonus reward earne by the manager for the ith project are represen by the arrays max employees/i] and bonus|i There is an array current_ employees, that represents the number of employees that are assigned to the ith project currently. Initially, only one employee is assigned to each project. So, current_ employees[i] = 1, for all O si< n. Now, the manager has m days to assign some employees to some projects. Each day the manager can do the following operation (may not perform any operation): • Choose any positive integer xand any project i. • Increase the current employees[i] to current_employees[i] + floor (current _employees(i]/x), where floor(num) is the largest integer less than or equal to num. After m days, a project x is said to be complete if current _employees/X/= max_employees[x] and the manager earns bonus[x] amount of money for that project. The total bonus earned by the manager is the sum of bonus of all the complete projects after m days.
Given n projects, m days, and two arrays max_ employees and bonus, find the maximum possible total_bonus that can be earned by the manager after m days. Example Given n = 4, m = 4, max_employees = [1, 7, 5 and bonus = [2, 6, 5, 2]. One of the optimal ways is explained below: One of the optimal ways is explained below: 1 1 1 1 —-Choose X = 1 and set current_employees[3] = 1 + floor(1/1) = 2 —> 1 1 1 2 —— Choose x= 1 and set current_employees[2] = 1 + floor(1/1) = 2 —-> 1 1 2 2 —— Choose x = 1 and set current employees[2] = 2 + floor(2/1) = 4 —-> 1 1 4 2 —— choose x= 4 and set current_employees[2] = 4 + floor(4/4) = 5 —> 1 1 5 2
After m days, current_ employees = [1, 1, 5, 2]. Here we have projects at indices 0, 2, and 3 completed. Hence the total_bonus is bonus[0] + bonus/27 + bonus(3] =2 + 5 + 2 = 9. Function Description Complete the function getMaxBones in the editor below. getMaxBonus takes the following arguments: int max_ employees[n]: the number of employees required for the projects int bonus[n]: the bonus earned by the manager for completing the projects int m: the number of days
Returns int: the maximum possible total_ bonus that can be earned by the manager after m days Constraints
- 1 ≤ n≤ 10^3
- 1 ≤ max_ employees[i] ≤ 10^3
- 1 ≤ bonus[i] ≤ 10^6
- 0 ≤ m≤ 10^6 int getMaxBonus (vector<int› max_employees, vector<int› bonus, int m) { }
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.