#P9051. [PA 2021] Wystawa
[PA 2021] Wystawa
Problem Description
You are given two sequences and of length .
You need to construct a sequence as follows:
- Choose indices and set .
- For all other , set .
Find the minimum possible value of the maximum subarray sum of sequence , and output one valid construction.
Input Format
The first line contains two integers .
The second line contains integers .
The third line contains integers .
Output Format
The first line contains one integer, the minimum possible value of the maximum subarray sum of sequence .
The second line contains a string of length . If , then ; otherwise, .
If there are multiple solutions, output any one of them.
6 2
-1 7 0 2 -5 0
3 1 4 -3 -3 12
4
BBABBA
3 2
-1 -4 -1
-4 -2 -1
0
AAB
Hint
For of the testdata, , , and .
Translated by ChatGPT 5