#P15868. 【MX-X26-T4】「Cfz Round 7」breakfast
【MX-X26-T4】「Cfz Round 7」breakfast
Background
An unending dream, an unbearable reality.
They will both eventually turn into ordinary scenery.
Problem Description
Yuki has a sequence of length .
For the sequence , Yuki defines its "Yuyu value" as:
$$\sum_{i=1}^n \operatorname{mex}(\{a_1,\dots,a_i\})$$That is, the sum of over all non-empty prefixes of .
Yuki defines one "bigger" operation as:
- Choose a positive integer not greater than and a non-negative integer , and change the value of to .
For each non-negative integer not greater than , you need to find: if Yuki performs exactly "bigger" operations, what is the maximum possible "Yuyu value" of the sequence .
In this problem, the of a sequence is the smallest non-negative integer that does not appear in the sequence. For example:
- ;
- ;
- ;
In particular, when the sequence is empty, its is .
Input Format
This problem contains multiple test cases.
The first line contains two integers , representing the subtask ID of this test point and the number of test cases. The sample satisfies .
Then each test case is given as follows:
- The first line contains an integer .
- The second line contains integers .
Output Format
For each test case, output one line containing integers. The -th integer means the maximum "Yuyu value" that the sequence can achieve if Yuki performs exactly "bigger" operations.
0 3
4
2 0 0 9
5
0 1 0 2 4
7
4 0 9 8 1 3 8
3 7 7 7 7
11 14 15 15 15 15
9 9 9 9 9 9 9 9
Hint
Sample 1 Explanation
For the -st test case:
- When , the "Yuyu value" of the sequence is .
- When , you can change to . Then the "Yuyu value" is .
For the -nd test case:
- When , the "Yuyu value" of the sequence is .
- When , you can change to . Then the "Yuyu value" is .
- When , you can change and to and respectively. Then the "Yuyu value" is .
Constraints
Let be the sum of within a single test point, and be the sum of within a single test point.
For all testdata:
- ;
- , ;
- For all , .
This problem uses bundled evaluation.
- Subtask 1 (13 points): , .
- Subtask 2 (17 points): , .
- Subtask 3 (27 points): , .
- Subtask 4 (7 points): The sequence is a permutation of to .
- Subtask 5 (15 points): The sequence is non-decreasing.
- Subtask 6 (21 points): No special constraints.
Translated by ChatGPT 5