#P7718. 「EZEC-10」Equalization
「EZEC-10」Equalization
Description
You are given an array of length .
You may choose any three integers , , and add to each of . This is called one operation.
Find the minimum number of operations needed to make all elements in equal, and also find the number of different optimal plans that achieve this minimum number of operations.
Since the number of plans may be very large, output it modulo .
Two plans are considered the same if and only if, for every operation, the chosen are exactly the same.
In particular, performing no operation is also considered a valid plan.
Input Format
The first line contains one integer .
The second line contains integers .
Output Format
The first line contains one integer, the minimum number of operations.
The second line contains one integer, the number of plans modulo .
3
1 2 3
2
16
Hint
[Sample 1 Explanation]
One feasible plan is: .
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (1 point): .
- Subtask 2 (5 points): .
- Subtask 3 (14 points): is guaranteed to be non-increasing or non-decreasing.
- Subtask 4 (20 points): .
- Subtask 5 (20 points): .
- Subtask 6 (40 points): no special restrictions.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号