#P12008. 【MX-X10-T4】[LSOT-4] Fragment of Memories
【MX-X10-T4】[LSOT-4] Fragment of Memories
Description
Before falling into a coma, Susan experienced days of memories. Starting from the first day, Susan has a base memory value . The memory for the -th day () is . These days of memories are concatenated in order to form a sequence of length .
In her dreams, this memory sequence is repeated times in order. Afterward, to awaken Susan, Luvia intervenes in the dream, inserting foreign memories not belonging to Susan. The final result is a sequence of length .
Given this sequence and , Luvia wants to determine the maximum possible value of for every possible base memory where . If no valid memory sequence exists for a particular , output .
Input Format
- The first line contains three integers , , , as described.
- The second line contains integers , representing the final sequence.
Output Format
Output one line containing integers, where the -th integer represents the maximum possible when .
9 2 5
2 1 3 4 5 2 3 2 4
0 3 2 1 0
30 3 8
3 4 5 5 1 2 8 4 5 3 6 4 5 7 5 6 6 7 6 8 7 1 8 2 3 2 7 3 7 8
0 2 1 2 1 2 2 1
Hint
Sample Explanation #1
For and , Susan's memory sequence is 2 3 4. Repeating times gives 2 3 4 2 3 4. After inserting values between positions and , and , and and , the sequence matches the original input.
Similarly, sequences like 2, 3, 4, 2 3, and 3 4 are all valid.
Data Range
This problem uses subtasks with bundled testing.
- Subtask 1 (13 pts): .
- Subtask 2 (21 pts): .
- Subtask 3 (23 pts): .
- Subtask 4 (25 pts): .
- Subtask 5 (18 pts): No additional constraints.
For all data: , .
Translation by DeepSeek R1
京公网安备 11011102002149号