Sobes.tech
Junior — Senior

Optimal revenue with daily production of goods

livecode

Task condition

Given an array of N positive integers, where each element represents the price of one unit of a product on the corresponding day. Each day, exactly one unit of product is produced and can be stored in the warehouse for an unlimited time. It is necessary to determine the maximum possible total revenue from all produced goods, provided that by the end of day N, the entire stock must be sold.

Example: 1 3 1 2 → 10