#C11925. Minimum Bonus Distribution
Minimum Bonus Distribution
Minimum Bonus Distribution
Given the performance scores of employees, you are required to distribute bonuses such that:
- Each employee receives at least one unit of bonus.
- If an employee has a higher score than an immediate neighbor, they must receive more bonus than that neighbor.
Formally, let (s_1, s_2, \dots, s_n) be the scores of (n) employees and (b_1, b_2, \dots, b_n) be the bonuses assigned. The following conditions must hold:
(b_i \ge 1) for all (i), if (s_i > s_{i-1}) then (b_i > b_{i-1}), and if (s_i > s_{i+1}) then (b_i > b_{i+1}).
Your task is to calculate the minimum total bonus (\sum_{i=1}^{n} b_i) that satisfies these conditions.
inputFormat
The input is given through standard input (stdin). The first line contains an integer (n), representing the number of employees. The second line contains (n) space-separated integers representing the scores of the employees.
outputFormat
Output a single integer to standard output (stdout) representing the minimum total bonus required.## sample
4
1 1 1 1
4
</p>