306511: CF1208F. Bits And Pieces
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Bits And Pieces
题意翻译
给定 $n$ 个数的数组 $d$,找到 $i\lt j\lt k $ 的 $i,j,k$,使得 $d_i|(d_j \& d_k)$ 最大题目描述
You are given an array $ a $ of $ n $ integers. You need to find the maximum value of $ a_{i} | ( a_{j} \& a_{k} ) $ over all triplets $ (i,j,k) $ such that $ i < j < k $ . Here $ \& $ denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and $ | $ denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR).输入输出格式
输入格式
The first line of input contains the integer $ n $ ( $ 3 \le n \le 10^{6} $ ), the size of the array $ a $ . Next line contains $ n $ space separated integers $ a_1 $ , $ a_2 $ , ..., $ a_n $ ( $ 0 \le a_{i} \le 2 \cdot 10^{6} $ ), representing the elements of the array $ a $ .
输出格式
Output a single integer, the maximum value of the expression given in the statement.
输入输出样例
输入样例 #1
3
2 4 6
输出样例 #1
6
输入样例 #2
4
2 8 4 7
输出样例 #2
12