#P12150. 【MX-X11-T4】「蓬莱人形 Round 1」视奸
【MX-X11-T4】「蓬莱人形 Round 1」视奸
Description
A set pair is defined as "good" if and only if can be transformed into through a finite number of the following operations:
- Choose a number from , remove from , then add and to . If duplicates exist, only one copy is retained.
Given that the initial value ranges of sets and are (containing integers), operations may produce values outside . Additionally, you are given the set and a length- array .
Find a valid such that is good, and minimize the sum .
Input Format
Multiple test cases.
The first line contains two integers and , representing the subtask number and the number of test cases, respectively. Subsequent lines contain the test data. Sample inputs satisfy .
For each test case:
- The first line contains an integer , the initial value range of sets and .
- The second line contains a length- binary string , where indicates , and indicates .
- The third line contains integers .
Output Format
For each test case, output a single integer representing the minimal possible sum.
0 2
9
100110011
3 0 -1 -3 4 -1 -4 -3 -5
8
10100101
2 0 2 4 1 1 2 2
-4
2
Hint
Explanation #1
For the first test case, is a valid solution. The cost is .
For the second test case, is valid. Operating on and transforms into , which matches . The cost is .
Constraints
For all test data: , , .
| Subtask | Special Property | Points | |
|---|---|---|---|
| 1 | 18 | None | 10 |
| 2 | A | ||
| 3 | B | 20 | |
| 4 | C | ||
| 5 | None | 40 |
- Special Property A: The size of set does not exceed 10.
- Special Property B: The binary string contains no substring
101. - Special Property C: All are equal.
Translated by DeepSeek R1
京公网安备 11011102002149号