Hard
,Array
,DP
,Greedy
,Sorting
A chef has collected data on the satisfaction
level of his n
dishes. Chef can cook any dish in 1 unit of time.
Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i]
.
Return the maximum sum of like-time coefficient that the chef can obtain after dishes preparation.
Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.
Example 1:
Example 2:
Example 3:
Constraints:
days.length
<= 365days[i]
<= 365days
is in strictly increasing order.costs.length
== 3costs[i]
<= 1000作法: Greedy,先對菜餚做排序,價值越高的菜餚要累加越多次,直到當前滿意度 < 0 時,則停止計算
Ron ChenWed, Mar 29, 2023
Yen-Chi ChenWed, Mar 29, 2023
gpwork4uThur, Mar 30, 2023
Yen-Chi ChenWed, Mar 29, 2023
MarsgoatWed, Mar 29, 2023