#K60242. Minimum Total Bonus
Minimum Total Bonus
Minimum Total Bonus
You are employed by a company that wants to distribute bonuses to its employees based on their performance scores. The rules are as follows:
- Each employee must receive at least 1 unit of bonus.
- If an employee has a higher performance score than his/her immediate neighbor, then he/she must receive strictly more bonus than that neighbor.
Your task is to compute the minimum total bonus the company must distribute for each test case. In other words, if we denote the bonus for employee i by \( bonus[i] \), then the following conditions must hold for every employee:
\( bonus[i] \ge 1 \)
if \( score[i] > score[i-1] \) then \( bonus[i] > bonus[i-1] \)
if \( score[i] > score[i+1] \) then \( bonus[i] > bonus[i+1] \)
Determine the minimum sum of all bonuses that satisfies these conditions.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains an integer \( T \) indicating the number of test cases.
- Each test case begins with a line containing an integer \( N \) which represents the number of employees.
- If \( N > 0 \), the next line contains \( N \) space-separated integers representing the performance scores of the employees.
outputFormat
For each test case, output a single integer on a new line via standard output (stdout) representing the minimum total bonus required to meet the conditions.
## sample2
3
1 2 2
4
1 2 2 3
4
6
</p>