#Q23. 「一本通 1.3 例 5」weight
「一本通 1.3 例 5」weight
Description
Original source: USACO
Given the sums of the first , first , first , , first terms, as well as the sums of the last , last , last , , last terms of the original sequence , but all numbers have been shuffled. Additionally, we know that all elements in the sequence belong to the set . The task is to reconstruct the original sequence. If multiple sequences are possible, output the lexicographically smallest one.
Input Format
Line : An integer .
Line : integers, note: the data has been shuffled.
Line : An integer , the size of set .
Line : integers, representing the elements of set .
Output Format
Output the lexicographically smallest sequence that satisfies the conditions.
Sample 1
5
1 2 5 7 7 9 12 13 14 14
4
1 2 4 5
1 1 5 2 5
Data Range and Hints
Data Range
For of the data, , , and .
Sample Explanation
| Sum from Left to Right | Sum from Right to Left |
|---|---|