#P16699. [MCO 2026] 知道得越少越好
[MCO 2026] 知道得越少越好
Problem Description
The dragon Evirir wrote pages about Olympiad in Informatics. For each integer , there is exactly one page whose amount of knowledge is . Evirir will bind these pages into a book. Formally, Evirir will choose a sequence of length consisting of pairwise distinct integers from to . Then, it will make a book such that page () has knowledge amount .
Due to ancient dragon laws, the knowledge amounts of some pages are fixed. The law gives integers . For each , if , then it must hold that . There are exactly values of with .
Evirir wants its students (numbered ) to read the whole book. However, due to short attention spans, each student will only read pages . A student's knowledge gain is defined as the sum of the knowledge amounts of the pages that the student reads.
If Evirir binds these pages in an optimal way, what is the maximum possible total knowledge gain of all students?
Input Format
The first line contains three integers , , and , separated by spaces.
The second line contains integers , separated by spaces.
The next lines follow. The -th of them contains two integers and , separated by spaces.
Output Format
Output one integer, the maximum possible total knowledge gain for all students.
5 2 5
3 4 1 0 2
0 2
1 4
15
5 3 2
2 -1 -1 1 -1
2 2
0 0
3 4
10
5 3 0
-1 -1 -1 -1 -1
1 3
4 4
0 4
20
Hint
Hint
This sample applies to subtasks 1, 4, and 6.
Evirir wrote pages, and there are students. All pages are fixed.
- Student 0 reads pages 0 to 2 and gains knowledge.
- Student 1 reads pages 1 to 4 and gains knowledge.
Therefore, the total knowledge gain is .
This sample applies to subtasks 4 and 6.
There are fixed pages: 0 and 3. One optimal binding is .
- Student 0 reads pages 2 to 2 and gains knowledge.
- Student 1 reads pages 0 to 0 and gains knowledge.
- Student 2 reads pages 3 to 4 and gains knowledge.
The total knowledge gain is . Note that there may be other optimal bindings.
Some examples of that Evirir cannot choose:
- : page 0 is fixed as , but here .
- : the knowledge amounts are not pairwise distinct.
- : the knowledge amounts must be between 0 and .
This sample applies to subtasks 3, 4, and 6.
Since , no page has a fixed knowledge amount. One optimal binding is .
- Student 0 reads pages 1 to 3 and gains knowledge.
- Student 1 reads pages 4 to 4 and gains knowledge.
- Student 2 reads pages 0 to 4 and gains knowledge.
The total knowledge gain is .
Scoring
For all testdata, the input satisfies the following constraints:
- For all ,
- There are exactly indices such that
- All fixed values are pairwise distinct: if and and , then
- For all ,
| Subtask | Points | Additional Constraints |
|---|---|---|
| , | ||
| , , for all , | ||
| , | ||
| for all , | ||
| -- |
Translated by ChatGPT 5