#P6891. [JOISC 2020] ビルの飾り付け 4
[JOISC 2020] ビルの飾り付け 4
Description
Given two sequences of length , construct a sequence of length that satisfies the following conditions:
-
For , can only be chosen from and .
-
The number of times is chosen from and the number of times it is chosen from are both exactly .
-
is a non-decreasing sequence.
If there are multiple valid sequences , you only need to output one.
Input Format
The first line contains a positive integer .
The second line contains numbers, where the -th number is .
The third line contains numbers, where the -th number is .
Output Format
If there is no solution, output . Otherwise, output a string in the following way:
For , if is chosen from , then ; otherwise, .
3
2 5 4 9 15 11
6 7 6 8 12 14
AABABB
2
1 4 10 20
3 5 8 13
BBAA
2
3 4 5 6
10 9 8 7
-1
6
25 18 40 37 29 95 41 53 39 69 61 90
14 18 22 28 18 30 32 32 63 58 71 78
BABBABAABABA
Hint
Sample 1 Explanation
The constructed . You can check for yourself that this satisfies the conditions.
Sample 2 Explanation
There are also other solutions: $\texttt{AABB}, \texttt{ABAB}, \texttt{BABA}, \texttt{BAAB}, \texttt{ABBA}$. Any one of them is acceptable.
Sample 3 Explanation
There is no solution that satisfies the conditions.
Subtasks
| Subtask | Special Property | Score |
|---|---|---|
| None |
Constraints
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号