#P6725. [COCI 2015/2016 #5] PERICA
[COCI 2015/2016 #5] PERICA
Description
Given a sequence of length , .
Please compute the sum of the maximum value over all combinations of numbers, modulo .
Input Format
The first line contains two integers .
The second line contains a sequence of length : .
Output Format
Output one integer on one line: the sum of the maximum value over all combinations of numbers, modulo .
5 3
2 4 2 3 4
39
5 1
1 0 1 1 1
4
5 2
3 3 4 0 0
31
Hint
Sample Explanation
Sample
All combinations of numbers are: $[2, 4, 2], [2, 4, 3], [2, 4, 4], [2, 2, 3], [2, 2, 4], [2, 3, 4], [4, 2, 3], [4, 2, 4], [4, 3, 4], [2, 3, 4]$.
Constraints
For of the testdata, .
For of the testdata, , .
Notes
Translated from COCI2015-2016 CONTEST #5 T3 PERICA。
Translated by ChatGPT 5
京公网安备 11011102002149号