#P17317. [KismetOI 2026 I] 作弊
[KismetOI 2026 I] 作弊
Problem Description
cobeder has started holding rated contests. Little A participated in contests, and the perf value of the -th contest is (). The cobeder system has a constant and an array . Little A’s rating can be computed as follows:
- If , then the rating equals $g_{\max\limits_{i=0}^{n}(\sum\limits_{j=1}^{i}p_j)}$.
- If , let $\text{maxp} = \max\limits_{i=0}^{k}(\sum\limits_{j=1}^{i}p_j)$. Then the rating equals .
In particular, when , set .
Little A hacked into cobeder’s system and wants to take this chance to modify his rating. Specifically, Little A has an integer (). He may choose some contests such that, when computing the rating and if , during the computation of , the values are all replaced by (that is, it does not affect the case , nor does it affect the value of when ).
To avoid being exposed, it must hold that for , . Let denote, for a perf sequence , the maximum rating value he can finally obtain after modifications.
Since cobeder computes the perf value of each contest a bit slowly, Little A only obtained some of the perf values. Specifically, Little A got a sequence of length , where means the perf value for this contest has not been computed yet, but it must be some integer in .
Little A wants to know: given and , over all possible final perf sequences , what is the sum of ? Output the answer modulo .
Input Format
The first line contains four integers .
The second line contains integers .
The third line contains integers .
Output Format
Output one integer in one line, representing the answer.
3 2 2 3
-7912 3 -2
1 1 2 3 4 5 5
152
5 2 2 3
-1 3 -2 -7912 -7912
0 0 2 3 3 4 5
900
5 2 2 3
-7912 3 -2 -7912 -7912
0 0 2 3 3 4 5
7895
5 7 2 5
-5 -7912 0 -7912 -7912
0 0 0 168 303 303 508 508 508 690 690 828 828 828 1005 1005 1005 1190 1190 1190 1190 1190 1190 1217 1217 1287 1600 1600 1600 1600 1600 1600 1600 1600 1600 1600
45661
Hint
Sample Explanation #1
One possible original perf sequence is . Then . One optimal operation is to modify to , and then for this sequence, .
Constraints
For all data, it holds that:
- .
- .
- .
- and each is an integer.
- .
- , and for , it is guaranteed that .
::cute-table{tuack} | | | | | | Special Properties | Score | | :--------------: | :----: | :------: | :------: | :--------: | :----------------: | :--: | | #1 | | | | | All are the same. | | | #2 | | | | ^ | . | | | #3 | | | | ^ | None. | | | #4 | | | | ^ | ^ | | | #5 | | | | | ^ | | | #6 | ^ | | | | ^ | | | #7 | ^ | | | ^ | For all with , it holds that . | | | #8 | ^ | ^ | ^ | ^ | None. | |
Translated by ChatGPT 5