#K93052. Minimum Effort to Make Tree Heights Unique
Minimum Effort to Make Tree Heights Unique
Minimum Effort to Make Tree Heights Unique
You are given T test cases. In each test case, you are given an integer N followed by N integers representing the heights of trees. Your task is to determine the minimum total effort required to make all tree heights unique. The only allowed operation is to increase the height of a tree. Increasing the height of a tree by 1 unit costs 1 unit of effort. After adjustments, all tree heights must be unique.
More formally, for a given sorted sequence (a_1, a_2, \dots, a_N), you need to transform it into a sequence (b_1, b_2, \dots, b_N) such that (b_1 < b_2 < \dots < b_N) with (b_i \geq a_i) and the total cost (\sum_{i=1}^{N} (b_i - a_i)) is minimized.
Input/Output Format:
- The input is read from standard input (stdin).
- The output should be written to standard output (stdout) with each answer on a separate line.
inputFormat
The first line of input contains an integer T, the number of test cases. For each test case:
- The first line contains an integer N, the number of trees.
- The second line contains N space-separated integers representing the heights of the trees.
Input is provided via standard input.
outputFormat
For each test case, output a single line containing the minimum total effort required to make all tree heights unique.## sample
1
4
3 3 3 3
6
</p>