You are given two independent coding problems.
There are n cities in a line (indexed 1..n). City i has population population[i].
Initially, some cities contain one security unit and others contain none. You are given an array unit[i] where:
unit[i] = 1
means city
i
initially has one unit
unit[i] = 0
means it has no unit
You may reassign units using these rules:
Goal: After performing moves, maximize the total population of protected cities.
Task: Return the maximum possible protected population sum.
You are given an array customer_rating of length n (assume all values are non-negative integers).
You may perform the following operation at most k times in total:
i
and do
customer_rating[i] += 1
.
After performing up to k increments, you must:
new_rating
.
Goal: Maximize new_rating.
Task: Return the maximum possible new_rating achievable with at most k total +1 operations.