#P7853. 「EZEC-9」进位
「EZEC-9」进位
Description
You are given a binary number (provided as a string of length ) and a sequence of length .
You also need to perform operations on .
In the -th operation, . Its value is the number of bit positions that change in before and after the operation, i.e., $v_i = \operatorname{popcount}(B \mathbin{\mathrm{xor}} (B + 2^{a_i}))$.
You need to solve two problems:
-
You may arrange the order of operations arbitrarily. After performing all operations, what is the maximum possible value of ?
-
You may arrange the order of operations arbitrarily. After performing all operations, what is the maximum possible value of ?
Input Format
The first line contains two integers .
The second line contains a string of length , representing the binary number , given from the least significant bit to the most significant bit.
The third line contains integers .
Output Format
The first line contains one integer, the answer to the first question.
The second line contains one integer, the answer to the second question.
This problem uses Special Judge. If your answer to the first question is correct, you can get of the score for that test point. If your answer to the second question is correct, you can get another of the score for that test point.
If you answer only one of the two questions, please output a non-negative integer in the other position.
5 6
10110
1 0 2 2 2 2
14
6
10 10
0101010110
0 1 2 3 4 5 5 4 3 2
21
9
10 3
1111101111
5 5 0
13
11
Hint
[Sample Explanation #1]
For the first question, performing operations in order can achieve .
For the second question, performing operations in order can achieve .
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (20 points): is all , and , .
- Subtask 4 (20 points): .
- Subtask 5 (10 points): no special restrictions.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号