Kaosar and AND#12324

Kaosar and AND (Editorial)

Problem Author:

AlKaosar Hussain

Prepared by:

AlKaosar Hussain

Edited by:

Hasan Saleh (MathModel)

Solution

Notice that for two integers that x \ \mathtt{AND} \ y \le \min(x,y) , because at the best case which is where both and share all turned on bits , which can be at most equal to \min(x,y) , thus the best option is just to choose the maximum element of the array (subsequence of length ).

\boxed{\underset{1 \le i \le n}{\max a_i}}

Complexity .

for _ in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    print(max(a))