#P5985. [PA 2019] Muzyka pop
[PA 2019] Muzyka pop
Description
Given integers , find non-negative integers to maximize the value of $a_1\times \operatorname{f(b_1)}+a_2\times \operatorname{f(b_2)}+...+a_n\times \operatorname{f(b_n)}$, where is the number of bits in the binary representation of .
The non-negative integers you find must satisfy .
Input Format
The first line contains two integers .
The second line contains integers .
Output Format
Output one integer in one line, which is the maximum value of $a_1\times \operatorname{f(b_1)}+a_2\times \operatorname{f(b_2)}+...+a_n\times \operatorname{f(b_n)}$.
3 5
2 -1 3
9
Hint
For of the testdata, , , and .
Explanation
Let . Then the answer is .
Translated by ChatGPT 5
京公网安备 11011102002149号