CF1237G Balanced Distribution
Description
There are $ n $ friends living on a circular street. The friends and their houses are numbered clockwise from $ 0 $ to $ n-1 $ .
Initially person $ i $ has $ a_i $ stones. The friends want to make the distribution of stones among them perfectly balanced: everyone should possess the same number of stones.
The only way to change the distribution of stones is by conducting meetings. During a meeting, people from exactly $ k $ consecutive houses (remember that the street is circular) gather at the same place and bring all their stones with them. All brought stones may be redistributed among people attending the meeting arbitrarily. The total number of stones they possess before the meeting and after the meeting must stay the same. After the meeting, everyone returns to their home.
Find a way to make the distribution of stones perfectly balanced conducting as few meetings as possible.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first example, the distribution of stones changes as follows:
- after the first meeting: $ 2 $ $ 6 $ $ \mathbf{7} $ $ \mathbf{3} $ $ \mathbf{4} $ $ 2 $ ;
- after the second meeting: $ \mathbf{4} $ $ \mathbf{2} $ $ 7 $ $ 3 $ $ 4 $ $ \mathbf{4} $ ;
- after the third meeting: $ 4 $ $ \mathbf{4} $ $ \mathbf{4} $ $ \mathbf{4} $ $ 4 $ $ 4 $ .
In the second example, the distribution of stones changes as follows:
- after the first meeting: $ 1 $ $ 0 $ $ 1 $ $ \mathbf{2} $ $ \mathbf{2} $ $ \mathbf{2} $ $ \mathbf{2} $ $ 2 $ $ 4 $ $ 3 $ $ 3 $ ;
- after the second meeting: $ \mathbf{5} $ $ 0 $ $ 1 $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ \mathbf{2} $ $ \mathbf{2} $ $ \mathbf{2} $ ;
- after the third meeting: $ \mathbf{2} $ $ \mathbf{2} $ $ \mathbf{2} $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ 2 $ $ \mathbf{2} $ .