How to solve this problem?

Revision en1, by _humblefool_, 2021-11-21 20:22:08

Given an array A of N elements, you can pick at most one element of the array and increment or decrement it by any value. The task is to maximize the AND of the resulting array.

Note: AND of the array is defined as the bitwise AND(&) of all the array elements.

Constraints: 2 ≤ N ≤ 2 * 105 0 ≤ A[i] ≤ 2 * 109

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English _humblefool_ 2021-11-21 20:23:19 2 Tiny change: 'N ≤ 2 * 105\n0 ≤ A[i] ≤ 2 * 109' -> 'N ≤ 2 * 10^5\n0 ≤ A[i] ≤ 2 * 10^9'
en1 English _humblefool_ 2021-11-21 20:22:08 342 Initial revision (published)