atcoder#ARC079C. [ARC079E] Decrease (Judge ver.)
[ARC079E] Decrease (Judge ver.)
Score : points
Problem Statement
We have a sequence of length consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes or smaller. (The operation is the same as the one in Problem D.)
- Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by , and increase each of the other elements by .
It can be proved that the largest element in the sequence becomes or smaller after a finite number of operations.
You are given the sequence . Find the number of times we will perform the above operation.
Constraints
Input
Input is given from Standard Input in the following format:
...
Output
Print the number of times the operation will be performed.
4
3 3 3 3
0
3
1 0 3
1
2
2 2
2
7
27 0 0 0 0 0 0
3
10
1000 193 256 777 0 1 1192 1234567891011 48 425
1234567894848