Company: Infosys SP-Off campus -17-May-26-Slot-1
Difficulty: medium
You are given an array A of N integers, an integer K, and an integer X. You can perform an operation at most K times. In one operation, you choose an index i (0-indexed) and replace A[i] with A[i] XOR X. Your objective is to maximize the sum of all elements in the array after performing these operations. Find the maximum total sum achievable. Input Format The first line contains a integer, N, denoting the number of elements in the array. The second line contains a integer, K, denoting the maximum number of operations allowed. The third line contains a integer, X, denoting the value to XOR with chosen elements. Each line i of the N subsequent lines (where 0 ≤ i Constraints 1 0 0 0 Sample Test Cases Case 1 Input: 3 1 3 1 2 3 Output: 7 Explanation: The element A[0]=1 changes to 1 XOR 3 = 2, yielding a gain of 1. Since K=1, we perform this operation, increasing the total sum from 6 to 7. Case 2 Input: 3 5 5 10 20 30 Output: 65 Explanation: A[0]=10 changes to 10 XOR 5 = 15 and despite K=5 o